From 2a98ad5c2c331d9e7a8d35aa00eaed0ec9ae5f19 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284872 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/CachedHashString.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/CachedHashString.h b/include/llvm/ADT/CachedHashString.h index c3688cb6978..c86726e95d3 100644 --- a/include/llvm/ADT/CachedHashString.h +++ b/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.49.0