OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 typedef T EmptyValueType; | 79 typedef T EmptyValueType; |
80 | 80 |
81 static T emptyValue() { return T(); } | 81 static T emptyValue() { return T(); } |
82 | 82 |
83 // Type for functions that do not take ownership, such as contains. | 83 // Type for functions that do not take ownership, such as contains. |
84 typedef const T& PeekInType; | 84 typedef const T& PeekInType; |
85 typedef T* IteratorGetType; | 85 typedef T* IteratorGetType; |
86 typedef const T* IteratorConstGetType; | 86 typedef const T* IteratorConstGetType; |
87 typedef T& IteratorReferenceType; | 87 typedef T& IteratorReferenceType; |
88 typedef const T& IteratorConstReferenceType; | 88 typedef const T& IteratorConstReferenceType; |
89 static IteratorConstGetType getToConstGetConversion(const T* x) { return x; } | |
tkent
2014/03/03 10:19:57
Why do you remove this line?
Mads Ager (chromium)
2014/03/03 10:20:50
Because it is unused in the code base. :)
tkent
2014/03/03 10:23:43
I see. I don't think we should include this chang
Mads Ager (chromium)
2014/03/03 10:30:35
It seems to me that removing dead code is always a
| |
90 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; } | 89 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; } |
91 static IteratorConstReferenceType getToReferenceConstConversion(Iterator ConstGetType x) { return *x; } | 90 static IteratorConstReferenceType getToReferenceConstConversion(Iterator ConstGetType x) { return *x; } |
92 // Type for functions that take ownership, such as add. | 91 // Type for functions that take ownership, such as add. |
93 // The store function either not be called or called once to store somet hing passed in. | 92 // The store function either not be called or called once to store somet hing passed in. |
94 // The value passed to the store function will be PassInType. | 93 // The value passed to the store function will be PassInType. |
95 typedef const T& PassInType; | 94 typedef const T& PassInType; |
96 static void store(const T& value, T& storage) { storage = value; } | 95 static void store(const T& value, T& storage) { storage = value; } |
97 | 96 |
98 // Type for return value of functions that transfer ownership, such as t ake. | 97 // Type for return value of functions that transfer ownership, such as t ake. |
99 typedef T PassOutType; | 98 typedef T PassOutType; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 183 |
185 typedef PassRefPtr<P> PassOutType; | 184 typedef PassRefPtr<P> PassOutType; |
186 static PassOutType passOut(RefPtr<P>& value) { return value.release(); } | 185 static PassOutType passOut(RefPtr<P>& value) { return value.release(); } |
187 static PassOutType passOut(std::nullptr_t) { return nullptr; } | 186 static PassOutType passOut(std::nullptr_t) { return nullptr; } |
188 | 187 |
189 typedef P* PeekOutType; | 188 typedef P* PeekOutType; |
190 static PeekOutType peek(const RefPtr<P>& value) { return value.get(); } | 189 static PeekOutType peek(const RefPtr<P>& value) { return value.get(); } |
191 static PeekOutType peek(std::nullptr_t) { return 0; } | 190 static PeekOutType peek(std::nullptr_t) { return 0; } |
192 }; | 191 }; |
193 | 192 |
193 template<typename T> struct HashTraits<RawPtr<T> > : SimpleClassHashTraits<R awPtr<T> > { | |
194 static const bool needsDestruction = false; | |
195 typedef T* PeekInType; | |
196 typedef T* PassInType; | |
197 typedef RawPtr<T>* IteratorGetType; | |
198 typedef const RawPtr<T>* IteratorConstGetType; | |
199 typedef RawPtr<T>& IteratorReferenceType; | |
200 typedef T* const IteratorConstReferenceType; | |
Mikhail
2014/03/03 10:25:56
could I ask why 'IteratorReferenceType' and 'Itera
Mads Ager (chromium)
2014/03/03 10:29:00
Yes, there is no reason for the extra indirection
| |
201 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; } | |
202 static IteratorConstReferenceType getToReferenceConstConversion(Iterator ConstGetType x) { return x->get(); } | |
203 typedef T* PeekOutType; | |
204 typedef T* PassOutType; | |
205 | |
206 template<typename U> | |
207 static void store(const U& value, RawPtr<T>& storage) { storage = value; } | |
208 | |
209 static PeekOutType peek(const RawPtr<T>& value) { return value; } | |
210 static PassOutType passOut(const RawPtr<T>& value) { return value; } | |
211 }; | |
212 | |
194 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { | 213 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { |
195 static const bool hasIsEmptyValueFunction = true; | 214 static const bool hasIsEmptyValueFunction = true; |
196 static bool isEmptyValue(const String&); | 215 static bool isEmptyValue(const String&); |
197 }; | 216 }; |
198 | 217 |
199 // This struct template is an implementation detail of the isHashTraitsEmpty Value function, | 218 // This struct template is an implementation detail of the isHashTraitsEmpty Value function, |
200 // which selects either the emptyValue function or the isEmptyValue function to check for empty values. | 219 // which selects either the emptyValue function or the isEmptyValue function to check for empty values. |
201 template<typename Traits, bool hasEmptyValueFunction> struct HashTraitsEmpty ValueChecker; | 220 template<typename Traits, bool hasEmptyValueFunction> struct HashTraitsEmpty ValueChecker; |
202 template<typename Traits> struct HashTraitsEmptyValueChecker<Traits, true> { | 221 template<typename Traits> struct HashTraitsEmptyValueChecker<Traits, true> { |
203 template<typename T> static bool isEmptyValue(const T& value) { return T raits::isEmptyValue(value); } | 222 template<typename T> static bool isEmptyValue(const T& value) { return T raits::isEmptyValue(value); } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 }; | 308 }; |
290 | 309 |
291 } // namespace WTF | 310 } // namespace WTF |
292 | 311 |
293 using WTF::HashTraits; | 312 using WTF::HashTraits; |
294 using WTF::PairHashTraits; | 313 using WTF::PairHashTraits; |
295 using WTF::NullableHashTraits; | 314 using WTF::NullableHashTraits; |
296 using WTF::SimpleClassHashTraits; | 315 using WTF::SimpleClassHashTraits; |
297 | 316 |
298 #endif // WTF_HashTraits_h | 317 #endif // WTF_HashTraits_h |
OLD | NEW |