[llvm-commits] [llvm] r46227 - /llvm/trunk/include/llvm/ADT/ImmutableSet.h
Ted Kremenek
kremenek at apple.com
Mon Jan 21 14:50:38 PST 2008
Author: kremenek
Date: Mon Jan 21 16:50:37 2008
New Revision: 46227
URL: http://llvm.org/viewvc/llvm-project?rev=46227&view=rev
Log:
Adjusted ImutAVLTree::ComputeHash to compute a hash value that is based on a
clearer sequence of hashing compositions.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableSet.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=46227&r1=46226&r2=46227&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Mon Jan 21 16:50:37 2008
@@ -210,11 +210,24 @@
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() {
More information about the llvm-commits
mailing list