Changeset 157049 in webkit
- Timestamp:
- Oct 7, 2013 11:07:54 AM (11 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r157044 r157049 1 2013-10-07 Anders Carlsson <andersca@apple.com> 2 3 Remove passIn and passOut from HashTraits 4 https://bugs.webkit.org/show_bug.cgi?id=122452 5 6 Reviewed by Sam Weinig. 7 8 Change RefPtrHashMap to not use passOut (just like the regular HashMap) and get rid of the 9 passIn and passOut functions and related typedefs. 10 11 * wtf/HashTraits.h: 12 * wtf/RefPtrHashMap.h: 13 1 14 2013-10-06 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WTF/wtf/HashTraits.h
r156507 r157049 65 65 static T emptyValue() { return T(); } 66 66 67 // Type for functions that take ownership, such as add.68 // The store function either not be called or called once to store something passed in.69 // The value passed to the store function will be either PassInType or PassInType&.70 typedef const T& PassInType;71 static void store(const T& value, T& storage) { storage = value; }72 73 // Type for return value of functions that transfer ownership, such as take.74 typedef T PassOutType;75 static PassOutType passOut(const T& value) { return value; }76 static T& passOut(T& value) { return value; } // Overloaded to avoid copying of non-temporary values.77 78 67 // Type for return value of functions that do not transfer ownership, such as get. 79 // FIXME: We could change this type to const T& for better performance if we figured out80 // a way to handle the return value from emptyValue, which is a temporary.81 68 typedef T PeekType; 82 69 static PeekType peek(const T& value) { return value; } … … 136 123 static P* emptyValue() { return 0; } 137 124 138 typedef PassRefPtr<P> PassInType;139 static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = value; }140 141 typedef PassRefPtr<P> PassOutType;142 static PassRefPtr<P> passOut(RefPtr<P>& value) { return value.release(); }143 static PassRefPtr<P> passOut(P* value) { return value; }144 145 125 typedef P* PeekType; 146 126 static PeekType peek(const RefPtr<P>& value) { return value.get(); } -
trunk/Source/WTF/wtf/RefPtrHashMap.h
r156492 r157049 44 44 45 45 private: 46 typedef typename MappedTraits::PassInType MappedPassInType;47 typedef typename MappedTraits::PassOutType MappedPassOutType;48 46 typedef typename MappedTraits::PeekType MappedPeekType; 49 50 typedef typename std::add_lvalue_reference<MappedPassInType>::type MappedPassInReferenceType;51 47 52 48 typedef HashArg HashFunctions; … … 102 98 void clear(); 103 99 104 Mapped PassOutType take(const KeyType&); // efficient combination of get with remove105 Mapped PassOutType take(RawKeyType); // efficient combination of get with remove100 MappedType take(const KeyType&); // efficient combination of get with remove 101 MappedType take(RawKeyType); // efficient combination of get with remove 106 102 107 103 private: … … 307 303 308 304 template<typename T, typename U, typename V, typename W, typename MappedTraits> 309 typename HashMap<RefPtr<T>, U, V, W, MappedTraits>::MappedPassOutType 310 HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(const KeyType& key) 305 auto HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(const KeyType& key) -> MappedType 311 306 { 312 307 iterator it = find(key); 313 308 if (it == end()) 314 return MappedTraits:: passOut(MappedTraits::emptyValue());315 Mapped PassOutType result = MappedTraits::passOut(it->value);309 return MappedTraits::emptyValue(); 310 MappedType value = std::move(it->value); 316 311 remove(it); 317 return result; 318 } 319 320 template<typename T, typename U, typename V, typename W, typename MappedTraits> 321 typename HashMap<RefPtr<T>, U, V, W, MappedTraits>::MappedPassOutType 322 HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(RawKeyType key) 312 return value; 313 } 314 315 template<typename T, typename U, typename V, typename W, typename MappedTraits> 316 auto HashMap<RefPtr<T>, U, V, W, MappedTraits>::take(RawKeyType key) -> MappedType 323 317 { 324 318 iterator it = find(key); 325 319 if (it == end()) 326 return MappedTraits:: passOut(MappedTraits::emptyValue());327 Mapped PassOutType result = MappedTraits::passOut(it->value);320 return MappedTraits::emptyValue(); 321 MappedType value = std::move(it->value); 328 322 remove(it); 329 return result;323 return value; 330 324 } 331 325
Note: See TracChangeset
for help on using the changeset viewer.