From c9d66eb05b3e76e3d33e4f11525ef888f1629234 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Fri, 21 Oct 2016 20:10:51 +0000 Subject: [PATCH] [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 llvm-svn: 284872 --- llvm/include/llvm/ADT/CachedHashString.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/CachedHashString.h b/llvm/include/llvm/ADT/CachedHashString.h index c3688cb..c86726e 100644 --- a/llvm/include/llvm/ADT/CachedHashString.h +++ b/llvm/include/llvm/ADT/CachedHashString.h @@ -61,7 +61,8 @@ template <> struct DenseMapInfo { } static bool isEqual(const CachedHashStringRef &LHS, const CachedHashStringRef &RHS) { - return DenseMapInfo::isEqual(LHS.val(), RHS.val()); + return LHS.hash() == RHS.hash() && + DenseMapInfo::isEqual(LHS.val(), RHS.val()); } }; -- 2.7.4