forked from OSchip/llvm-project
[ADT] Allow llvm::hash_code as DenseMap key.
Summary: This is useful when hash collisions are unlikely and acceptable, e.g. in clangd completion ranking. Reviewers: ioeric Subscribers: ilya-biryukov, llvm-commits Differential Revision: https://reviews.llvm.org/D48361 llvm-svn: 335125
This commit is contained in:
parent
d8b780dcd6
commit
03953093f9
|
@ -262,6 +262,13 @@ template <typename T> struct DenseMapInfo<ArrayRef<T>> {
|
|||
}
|
||||
};
|
||||
|
||||
template <> struct DenseMapInfo<hash_code> {
|
||||
static inline hash_code getEmptyKey() { return hash_code(-1); }
|
||||
static inline hash_code getTombstoneKey() { return hash_code(-2); }
|
||||
static unsigned getHashValue(hash_code val) { return val; }
|
||||
static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_ADT_DENSEMAPINFO_H
|
||||
|
|
Loading…
Reference in New Issue