From: Ted Kremenek Date: Mon, 21 Jan 2008 22:50:37 +0000 (+0000) Subject: Adjusted ImutAVLTree::ComputeHash to compute a hash value that is based on a X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c4125a3c44171f90639621c3c93182a7fe45b24e;p=oota-llvm.git Adjusted ImutAVLTree::ComputeHash to compute a hash value that is based on a clearer sequence of hashing compositions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46227 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h index 5118b0d3369..856667d1219 100644 --- a/include/llvm/ADT/ImmutableSet.h +++ b/include/llvm/ADT/ImmutableSet.h @@ -210,11 +210,24 @@ private: unsigned ComputeHash(ImutAVLTree* L, ImutAVLTree* R, value_type_ref V) { FoldingSetNodeID ID; - ID.AddInteger(L ? L->ComputeHash() : 0); + if (L) ID.AddInteger(L->ComputeHash()); ImutInfo::Profile(ID,V); - ID.AddInteger(R ? R->ComputeHash() : 0); - return ID.ComputeHash(); + // Compute the "intermediate" hash. Basically, we want the net profile to + // be: H(H(....H(H(H(item0),item1),item2)...),itemN), where + // H(item) is the hash of the data item and H(hash,item) is a hash + // of the last item hash and the the next item. + + unsigned X = ID.ComputeHash(); + ID.clear(); + + if (R) { + ID.AddInteger(X); + ID.AddInteger(R->ComputeHash()); + X = ID.ComputeHash(); + } + + return X; } inline unsigned ComputeHash() {