just a little nitpik in bfd
Nick Clifton
nickc@cambridge.redhat.com
Fri May 17 02:20:00 GMT 2002
Hi Stuart,
> In the core of bfd (binutils 2.11.92), in file hash.c in function
> bfd_hash_lookup, I see:
>
> > hash = 0;
> > len = 0;
> > s = (const unsigned char *) string;
> > while ((c = *s++) != '\0')
> > {
> > hash += c + (c << 17);
> > hash ^= hash >> 2;
> > ++len;
> > }
> > hash += len + (len << 17);
> > hash ^= hash >> 2;
>
> Surely, we can eliminate ++len from the loop, because it is an
> induction variable (and the compiler might do it for us, but we can
> and should code carefully first, then hope the compiler can do
> better):
Certainly - that would be a reasonable change - I will apply the patch
shortly.
> One more wrinkle: why do we need to hash len into the hash total?
It does no harm, and it might help in situations where a long string
with low numbered ascii characters has a similar hash value to a
shorter string with higher numbered ascii characters.
Cheers
Nick
More information about the Binutils
mailing list