Does any one know what the cache map hash function that generates a hash from a URL that mozilla firefox uses? I have allready found this http://benlast.livejournal.com/29164.html where it gives a pretty good example code, unfortunately I think it is outdated and not used anymore in the current version of Firefox.
Any help would be much appreciated.
Does any one know what the cache map hash function that generates a hash
Share
You can see the hash algorithm used by Firefox here: http://hg.mozilla.org/mozilla-central/file/09935ede3c77/netwerk/cache/nsDiskCacheDevice.cpp#l272. It is pretty simple but rather different from the one you linked to (I checked and the change happened between Firefox 3.5 and Firefox 3.6). Essentially, it seems to treat the URL as a sequence of unsigned integers (little-endian, padded with zeros as necessary) and adds them up to the variables
a,bandc(first and forth number toa, second and fifth tob, third and sixth toc). The three variables are then combined in functionhashmix().The initial value for
aandbis0x9e3779b9, the value forcis somewhat more complicated – it comes in as parameter. All callers use the default value of this parameter however which is 0 (seensDiskCache.h).I guess that http://burtleburtle.net/bob/hash/evahash.html might provide more info on the algorithm used.