Changeset 142924 in webkit
- Timestamp:
- Feb 14, 2013, 2:50:37 PM (12 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WTF/ChangeLog ¶
r142923 r142924 1 2013-02-14 Dan Bernstein <mitz@apple.com> 2 3 No easy way to use a RetainPtr as a key in a HashMap using object (rather than pointer) equality 4 https://bugs.webkit.org/show_bug.cgi?id=109864 5 6 Reviewed by Sam Weinig and Benjamin Poulain. 7 8 Added RetainPtrObjectHashTraits and RetainPtrObjectHash, which use CFEqual 9 and CFHash. 10 11 * wtf/RetainPtr.h: 12 (RetainPtrObjectHashTraits): 13 (WTF::RetainPtrObjectHashTraits::emptyValue): 14 (WTF::RetainPtrObjectHashTraits::constructDeletedValue): 15 (WTF::RetainPtrObjectHashTraits::isDeletedValue): 16 (WTF): 17 (WTF::RetainPtrObjectHash::hash): 18 (WTF::RetainPtrObjectHash::equal): 19 (RetainPtrObjectHash): 20 1 21 2013-02-14 Tony Chang <tony@chromium.org> 2 22 -
TabularUnified trunk/Source/WTF/wtf/RetainPtr.h ¶
r133793 r142924 298 298 template<typename P> struct DefaultHash<RetainPtr<P> > { typedef PtrHash<RetainPtr<P> > Hash; }; 299 299 300 template <typename P> 301 struct RetainPtrObjectHashTraits : GenericHashTraits<RetainPtr<P> > { 302 static const bool emptyValueIsZero = true; 303 static const RetainPtr<P>& emptyValue() 304 { 305 static RetainPtr<P>& null = *(new RetainPtr<P>); 306 return null; 307 } 308 static const bool needsDestruction = true; 309 static void constructDeletedValue(RetainPtr<P>& slot) { new (&slot) RetainPtr<P>(HashTableDeletedValue); } 310 static bool isDeletedValue(const RetainPtr<P>& value) { return value.isHashTableDeletedValue(); } 311 }; 312 313 template <typename P> 314 struct RetainPtrObjectHash { 315 static unsigned hash(const RetainPtr<P>& o) 316 { 317 ASSERT_WITH_MESSAGE(o.get(), "attempt to use null RetainPtr in HashTable"); 318 return CFHash(o.get()); 319 } 320 static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) 321 { 322 return CFEqual(a.get(), b.get()); 323 } 324 static const bool safeToCompareToEmptyOrDeleted = false; 325 }; 300 326 } // namespace WTF 301 327
Note:
See TracChangeset
for help on using the changeset viewer.