]> granicus.if.org Git - llvm/commitdiff
[ADT] Compare strings' hashes first before comparing their values.
authorJustin Lebar <jlebar@google.com>
Fri, 21 Oct 2016 20:10:51 +0000 (20:10 +0000)
committerJustin Lebar <jlebar@google.com>
Fri, 21 Oct 2016 20:10:51 +0000 (20:10 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284872 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/CachedHashString.h

index c3688cb69783b00f549ccdaa0dee7a61f6a30fa2..c86726e95d3178f1d9829855781c76c523f55993 100644 (file)
@@ -61,7 +61,8 @@ template <> struct DenseMapInfo<CachedHashStringRef> {
   }
   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());
   }
 };