Chromium Code Reviews| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 typedef PassOwnPtr<P> PassOutType; | 131 typedef PassOwnPtr<P> PassOutType; |
| 132 static PassOwnPtr<P> passOut(OwnPtr<P>& value) { return value.release(); } | 132 static PassOwnPtr<P> passOut(OwnPtr<P>& value) { return value.release(); } |
| 133 static PassOwnPtr<P> passOut(std::nullptr_t) { return nullptr; } | 133 static PassOwnPtr<P> passOut(std::nullptr_t) { return nullptr; } |
| 134 | 134 |
| 135 typedef typename OwnPtr<P>::PtrType PeekType; | 135 typedef typename OwnPtr<P>::PtrType PeekType; |
| 136 static PeekType peek(const OwnPtr<P>& value) { return value.get(); } | 136 static PeekType peek(const OwnPtr<P>& value) { return value.get(); } |
| 137 static PeekType peek(std::nullptr_t) { return 0; } | 137 static PeekType peek(std::nullptr_t) { return 0; } |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<R efPtr<P> > { | 140 template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<R efPtr<P> > { |
| 141 static RefPtr<P>& emptyValue() | 141 static P* emptyValue() { return 0; } |
| 142 { | |
| 143 static RefPtr<P>& null = *(new RefPtr<P>); | |
| 144 return null; | |
| 145 } | |
| 146 | 142 |
| 147 typedef PassRefPtr<P> PassInType; | 143 typedef PassRefPtr<P> PassInType; |
| 148 static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = v alue; } | 144 static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = v alue; } |
| 149 | 145 |
| 150 typedef PassRefPtr<P> PassOutType; | 146 typedef PassRefPtr<P> PassOutType; |
| 151 static PassRefPtr<P> passOut(RefPtr<P>& value) { return value.release(); } | 147 static PassRefPtr<P> passOut(RefPtr<P>& value) { return value.release(); } |
| 148 static PassRefPtr<P> passOut(P* value) { return value; } | |
|
eseidel
2013/05/06 18:38:59
What does this do? Is it safe?
| |
| 149 | |
| 152 // FIXME: We should consider changing PeekType to a raw pointer for bett er performance, | 150 // FIXME: We should consider changing PeekType to a raw pointer for bett er performance, |
| 153 // but then callers won't need to call get; doing so will require updati ng many call sites. | 151 // but then callers won't need to call get; doing so will require updati ng many call sites. |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { | 154 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { |
| 157 static const bool hasIsEmptyValueFunction = true; | 155 static const bool hasIsEmptyValueFunction = true; |
| 158 static bool isEmptyValue(const String&); | 156 static bool isEmptyValue(const String&); |
| 159 }; | 157 }; |
| 160 | 158 |
| 161 // This struct template is an implementation detail of the isHashTraitsEmpty Value function, | 159 // This struct template is an implementation detail of the isHashTraitsEmpty Value function, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 }; | 244 }; |
| 247 | 245 |
| 248 } // namespace WTF | 246 } // namespace WTF |
| 249 | 247 |
| 250 using WTF::HashTraits; | 248 using WTF::HashTraits; |
| 251 using WTF::PairHashTraits; | 249 using WTF::PairHashTraits; |
| 252 using WTF::NullableHashTraits; | 250 using WTF::NullableHashTraits; |
| 253 using WTF::SimpleClassHashTraits; | 251 using WTF::SimpleClassHashTraits; |
| 254 | 252 |
| 255 #endif // WTF_HashTraits_h | 253 #endif // WTF_HashTraits_h |
| OLD | NEW |