From: Nicolas C. <war...@fr...> - 2004-05-10 12:37:08
|
> (There was a discussion on this a few months ago on one of the lists > but I can't find it now ...) > > Does anyone have a library or code for sharing strings? I have a > program which processes a lot of data from a file, including repeated > strings, and it's important to minimize memory usage. > > Something like: > > open Shared > > let s = <string read from some source> in > let s = shared s > > where the 'shared' function would return either the same string, or an > identical string from a previous call to 'shared'. > > I'm aware of the problems of mutability with strings, but my program > can guarantee that I won't change the shared strings. > > Rich. What about using an Hashtbl ? It provides a fair comparison function based on hashed strings. Nicolas Cannasse |