[Patch, libgfortran] Better format hash function
Tobias Burnus
burnus@net-b.de
Thu Jun 4 18:57:00 GMT 2009
Janne Blomqvist wrote:
> the attached patch replaces the existing (too?) simple string hash
> function with an almost equally simple but supposedly pretty well
> working one by D.J. Bernstein.
>
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
>
OK. Thanks for the patch. It can only be better than the current one.
How about using
- Uses the DJB algorithm, which is simple
+ Uses the DJB algorithm by D.J. Bernstein, which is simple
I personally dislike acronyms which are hard to decipher.
Paolo Bonzini wrote:
>> but supposedly pretty well working one
> It's quite overrated (first collision took 30 seconds to find by hand:
> C# collides with BD), but it cannot be worse than what is there now.
Fortunately, in this case hash collisions do not matter thus much. The
hashes are only used to cache decoded format strings. If a collision
happens, the previous entry is simply overwritten. That costs only
performance but is not a correctness issue. And I believe (hope?) that
hash collisions in real-world codes are rather an exception than the norm.
Tobias
More information about the Fortran
mailing list