aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantsContext.h
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-03-07 03:22:32 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-03-07 03:22:32 +0000
commiteea81f32cdd2f0408aaf83878cf45b5024cf6b57 (patch)
treef0a93dda31c2d090783aaa15b7647333919a3f79 /lib/VMCore/ConstantsContext.h
parentf8cde7388eb96c59992bc4798ec9fca41ea1a13c (diff)
downloadexternal_llvm-eea81f32cdd2f0408aaf83878cf45b5024cf6b57.zip
external_llvm-eea81f32cdd2f0408aaf83878cf45b5024cf6b57.tar.gz
external_llvm-eea81f32cdd2f0408aaf83878cf45b5024cf6b57.tar.bz2
Switch this code to use hash_combine_range rather than incremental calls
to hash_combine. One of the interfaces could already do this, and the other can just use a small buffer. This is a much more efficient way to use the hash_combine interface, although I don't have any particular benchmark where this code was hot, so I can't measure much of an impact. It at least doesn't slow anything down. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantsContext.h')
-rw-r--r--lib/VMCore/ConstantsContext.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h
index 7f2198d..8903a8f 100644
--- a/lib/VMCore/ConstantsContext.h
+++ b/lib/VMCore/ConstantsContext.h
@@ -657,20 +657,18 @@ private:
return ConstantClassInfo::getTombstoneKey();
}
static unsigned getHashValue(const ConstantClass *CP) {
- hash_code code = hash_value(CP->getType());
+ SmallVector<Constant*, 8> CPOperands;
+ CPOperands.reserve(CP->getNumOperands());
for (unsigned I = 0, E = CP->getNumOperands(); I < E; ++I)
- code = hash_combine(code, hash_value(CP->getOperand(I)));
- return code;
+ CPOperands.push_back(CP->getOperand(I));
+ return getHashValue(LookupKey(CP->getType(), CPOperands));
}
static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
return LHS == RHS;
}
static unsigned getHashValue(const LookupKey &Val) {
- hash_code code = hash_value(Val.first);
- for (Operands::const_iterator
- I = Val.second.begin(), E = Val.second.end(); I != E; ++I)
- code = hash_combine(code, hash_value(*I));
- return code;
+ return hash_combine(Val.first, hash_combine_range(Val.second.begin(),
+ Val.second.end()));
}
static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
if (RHS == getEmptyKey() || RHS == getTombstoneKey())