[darcs-devel] darcs patch: add hash function to FastPackedString (and 1 more)

Ian Lynagh igloo at earth.li
Tue Apr 5 07:01:02 PDT 2005


On Tue, Apr 05, 2005 at 08:25:10AM -0400, Benedikt Schmidt wrote:
> 
> Tue Apr  5 14:31:55 CEST 2005  Benedikt Schmidt <beschmi at cloaked.de>
>   * replace Hunt/Szymanski diff algorithm with one by Myers

Do you have some comparison times, both for large common cases and also
for cases where H-S struggles?

> +foreign import ccall unsafe "fpstring.h hash" hash
> +    :: Ptr Word8 -> Int -> IO Int32
> +
> +int hash(const char *s, int len) {
> +  hash_value h = 0;
> +  int i;
> +  for (i=0;i<len;i++)
> +    h = HASH (h, s[i]);
> +  return h;
> +}

int in C is CInt in Haskell.
Int in Haskell is HsInt in C.
You shouldn't use Int with int.
(darcs could probably do with an audit for this)
((I haven't followed the code to see if signedness of chars can also be a
problem))
(((of course, IMO it should all be in Haskell anyway  :-)  )))


Thanks
Ian





More information about the darcs-devel mailing list