[llvm-commits] [llvm] r117880 - /llvm/trunk/include/llvm/ADT/DenseMapInfo.h
Chandler Carruth
chandlerc at gmail.com
Sun Oct 31 15:57:03 PDT 2010
Author: chandlerc
Date: Sun Oct 31 17:57:03 2010
New Revision: 117880
URL: http://llvm.org/viewvc/llvm-project?rev=117880&view=rev
Log:
Add a specialization for 'long', a hole in the set of fundamental
specializations provided here. This is a little annoying because its size
changes from platform to platform. If possible, I may follow up with a patch
that uses standard constants to simplify much of this, but assuming for now
that was avoided for a reason.
Modified:
llvm/trunk/include/llvm/ADT/DenseMapInfo.h
Modified: llvm/trunk/include/llvm/ADT/DenseMapInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMapInfo.h?rev=117880&r1=117879&r2=117880&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMapInfo.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMapInfo.h Sun Oct 31 17:57:03 2010
@@ -102,6 +102,20 @@
}
};
+// Provide DenseMapInfo for longs.
+template<> struct DenseMapInfo<long> {
+ static inline long getEmptyKey() {
+ return (1UL << (sizeof(long) * 8 - 1)) - 1L;
+ }
+ static inline long getTombstoneKey() { return getEmptyKey() - 1L; }
+ static unsigned getHashValue(const long& Val) {
+ return (unsigned)(Val * 37L);
+ }
+ static bool isEqual(const long& LHS, const long& RHS) {
+ return LHS == RHS;
+ }
+};
+
// Provide DenseMapInfo for long longs.
template<> struct DenseMapInfo<long long> {
static inline long long getEmptyKey() { return 0x7fffffffffffffffLL; }
More information about the llvm-commits
mailing list