• antirez's avatar
    dictFingerprint() fingerprinting made more robust. · 905d4822
    antirez authored
    The previous hashing used the trivial algorithm of xoring the integers
    together. This is not optimal as it is very likely that different
    hash table setups will hash the same, for instance an hash table at the
    start of the rehashing process, and at the end, will have the same
    fingerprint.
    
    Now we hash N integers in a smarter way, by summing every integer to the
    previous hash, and taking the integer hashing again (see the code for
    further details). This way it is a lot less likely that we get a
    collision. Moreover this way of hashing explicitly protects from the
    same set of integers in a different order to hash to the same number.
    
    This commit is related to issue #1240.
    905d4822
dict.c 25.8 KB