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

Side by Side Diff: Source/wtf/HashTraits.h

Issue 14877006: Optimization of HashTraits<RefPtr<P> >::emptyValue() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased. Created 7 years, 7 months 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 | « Source/wtf/HashTable.h ('k') | no next file » | 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, 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
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; }
152 149
153 typedef P* PeekType; 150 typedef P* PeekType;
154 static PeekType peek(const RefPtr<P>& value) { return value.get(); } 151 static PeekType peek(const RefPtr<P>& value) { return value.get(); }
155 }; 152 };
156 153
157 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { 154 template<> struct HashTraits<String> : SimpleClassHashTraits<String> {
158 static const bool hasIsEmptyValueFunction = true; 155 static const bool hasIsEmptyValueFunction = true;
159 static bool isEmptyValue(const String&); 156 static bool isEmptyValue(const String&);
160 }; 157 };
161 158
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 }; 244 };
248 245
249 } // namespace WTF 246 } // namespace WTF
250 247
251 using WTF::HashTraits; 248 using WTF::HashTraits;
252 using WTF::PairHashTraits; 249 using WTF::PairHashTraits;
253 using WTF::NullableHashTraits; 250 using WTF::NullableHashTraits;
254 using WTF::SimpleClassHashTraits; 251 using WTF::SimpleClassHashTraits;
255 252
256 #endif // WTF_HashTraits_h 253 #endif // WTF_HashTraits_h
OLDNEW
« no previous file with comments | « Source/wtf/HashTable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698