[Haskell-cafe] looking for optimization advice

Carl Witty cwitty at newtonlabs.com
Thu Mar 25 13:11:32 EST 2004


On Thu, 2004-03-25 at 12:26, David Roundy wrote:
> > If you compare strings more often than you create strings, and the
> > comparisons usually fail, you could add a hash of the string to your
> > PackedString datatype; then psniceq could compare hash values first and
> > only confirm equality with the memcmp if the hash values match.
> 
> In many cases, *very* large strings will be created and never compared, so
> hashing them doesn't sound like a good plan.

You could compute the hash lazily.  (Of course, if most of your time is
spent on successful comparisons, as you suspect, then none of the
measures I suggest for speeding up unsuccessful comparisons will help
much.  I do have more ideas along that line, though, if it turns out
that unsuccessful comparisons do take up too much time.)

Carl Witty




More information about the Haskell-Cafe mailing list