Skip to content

Commit

Permalink
[ADT] Compare strings' hashes first before comparing their values.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Justin Lebar committed Oct 21, 2016
1 parent d87ea9a commit c9d66eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/include/llvm/ADT/CachedHashString.h
Expand Up @@ -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());
}
};

Expand Down

0 comments on commit c9d66eb

Please sign in to comment.