[PATCH] D25705: [ADT] Compare strings' hashes first before comparing their values.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 15:17:06 PDT 2016


jlebar created this revision.
jlebar added a reviewer: rafael.
jlebar added a subscriber: llvm-commits.

We already have the hashes in hand, and comparing hashes should be much
more discriminatory than comparing the StringRefs' sizes.


https://reviews.llvm.org/D25705

Files:
  llvm/include/llvm/ADT/CachedHashString.h


Index: llvm/include/llvm/ADT/CachedHashString.h
===================================================================
--- llvm/include/llvm/ADT/CachedHashString.h
+++ llvm/include/llvm/ADT/CachedHashString.h
@@ -62,7 +62,8 @@
   }
   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());
   }
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25705.74919.patch
Type: text/x-patch
Size: 528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/8cbfca7f/attachment.bin>


More information about the llvm-commits mailing list