[llvm] r284872 - [ADT] Compare strings' hashes first before comparing their values.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 13:10:51 PDT 2016
Author: jlebar
Date: Fri Oct 21 15:10:51 2016
New Revision: 284872
URL: http://llvm.org/viewvc/llvm-project?rev=284872&view=rev
Log:
[ADT] Compare strings' hashes first before comparing their values.
Summary:
We already have the hashes in hand, and comparing hashes should be much
more discriminatory than comparing the StringRefs' sizes.
Reviewers: rafael
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25705
Modified:
llvm/trunk/include/llvm/ADT/CachedHashString.h
Modified: llvm/trunk/include/llvm/ADT/CachedHashString.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/CachedHashString.h?rev=284872&r1=284871&r2=284872&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/CachedHashString.h (original)
+++ llvm/trunk/include/llvm/ADT/CachedHashString.h Fri Oct 21 15:10:51 2016
@@ -61,7 +61,8 @@ template <> struct DenseMapInfo<CachedHa
}
static bool isEqual(const CachedHashStringRef &LHS,
const CachedHashStringRef &RHS) {
- return DenseMapInfo<StringRef>::isEqual(LHS.val(), RHS.val());
+ return LHS.hash() == RHS.hash() &&
+ DenseMapInfo<StringRef>::isEqual(LHS.val(), RHS.val());
}
};
More information about the llvm-commits
mailing list