Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: sky/engine/wtf/HashFunctions.h

Issue 722723003: Re-land 714393002 after fixing android build. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/wtf/EnumClass.h ('k') | sky/engine/wtf/InstanceCounter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b); 117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b);
118 } 118 }
119 static const bool safeToCompareToEmptyOrDeleted = true; 119 static const bool safeToCompareToEmptyOrDeleted = true;
120 }; 120 };
121 121
122 // pointer identity hash function 122 // pointer identity hash function
123 123
124 template<typename T> struct PtrHash { 124 template<typename T> struct PtrHash {
125 static unsigned hash(T key) 125 static unsigned hash(T key)
126 { 126 {
127 #if COMPILER(MSVC)
128 #pragma warning(push)
129 #pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's c onversion warnings
130 #endif
131 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key)); 127 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
132 #if COMPILER(MSVC)
133 #pragma warning(pop)
134 #endif
135 } 128 }
136 static bool equal(T a, T b) { return a == b; } 129 static bool equal(T a, T b) { return a == b; }
137 static bool equal(std::nullptr_t, T b) { return b == 0; } 130 static bool equal(std::nullptr_t, T b) { return b == 0; }
138 static bool equal(T a, std::nullptr_t) { return a == 0; } 131 static bool equal(T a, std::nullptr_t) { return a == 0; }
139 static const bool safeToCompareToEmptyOrDeleted = true; 132 static const bool safeToCompareToEmptyOrDeleted = true;
140 }; 133 };
141 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> { 134 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> {
142 using PtrHash<P*>::hash; 135 using PtrHash<P*>::hash;
143 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } 136 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
144 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); } 137 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // make IntHash the default hash function for many integer types 191 // make IntHash the default hash function for many integer types
199 192
200 template<> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; }; 193 template<> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; };
201 template<> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Ha sh; }; 194 template<> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Ha sh; };
202 template<> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; }; 195 template<> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; };
203 template<> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; }; 196 template<> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; };
204 template<> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; } ; 197 template<> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; } ;
205 template<> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long > Hash; }; 198 template<> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long > Hash; };
206 template<> struct DefaultHash<long long> { typedef IntHash<unsigned long lon g> Hash; }; 199 template<> struct DefaultHash<long long> { typedef IntHash<unsigned long lon g> Hash; };
207 template<> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Hash; }; 200 template<> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Hash; };
208
209 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
210 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; }; 201 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; };
211 #endif
212
213 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; }; 202 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; };
214 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; }; 203 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; };
215 204
216 // make PtrHash the default hash function for pointer types that don't speci alize 205 // make PtrHash the default hash function for pointer types that don't speci alize
217 206
218 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; }; 207 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
219 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; }; 208 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; };
220 template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr <P> > Hash; }; 209 template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr <P> > Hash; };
221 template<typename P> struct DefaultHash<OwnPtr<P> > { typedef PtrHash<OwnPtr <P> > Hash; }; 210 template<typename P> struct DefaultHash<OwnPtr<P> > { typedef PtrHash<OwnPtr <P> > Hash; };
222 211
(...skipping 20 matching lines...) Expand all
243 232
244 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; }; 233 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; };
245 234
246 } // namespace WTF 235 } // namespace WTF
247 236
248 using WTF::DefaultHash; 237 using WTF::DefaultHash;
249 using WTF::IntHash; 238 using WTF::IntHash;
250 using WTF::PtrHash; 239 using WTF::PtrHash;
251 240
252 #endif // WTF_HashFunctions_h 241 #endif // WTF_HashFunctions_h
OLDNEW
« no previous file with comments | « sky/engine/wtf/EnumClass.h ('k') | sky/engine/wtf/InstanceCounter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698