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

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

Issue 2065443002: Rename and improve "traceable" templates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment rewording Created 4 years, 6 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 static const bool hasIsEmptyValueFunction = false; 54 static const bool hasIsEmptyValueFunction = false;
55 55
56 // The starting table size. Can be overridden when we know beforehand that a 56 // The starting table size. Can be overridden when we know beforehand that a
57 // hash table will have at least N entries. 57 // hash table will have at least N entries.
58 #if defined(MEMORY_SANITIZER_INITIAL_SIZE) 58 #if defined(MEMORY_SANITIZER_INITIAL_SIZE)
59 static const unsigned minimumTableSize = 1; 59 static const unsigned minimumTableSize = 1;
60 #else 60 #else
61 static const unsigned minimumTableSize = 8; 61 static const unsigned minimumTableSize = 8;
62 #endif 62 #endif
63 63
64 // When a hash table backing store is traced, its elements will be
65 // traced if their class type has a trace method. However, weak-referenced
66 // elements should not be traced then, but handled by the weak processing
67 // phase that follows.
64 template <typename U = void> 68 template <typename U = void>
65 struct NeedsTracingLazily { 69 struct IsTraceableInCollection {
haraken 2016/06/12 07:11:31 Nit: I'm okay with keeping the word "lazily" to ma
sof 2016/06/12 07:29:44 None other than it would fail to compile, i think.
66 static const bool value = NeedsTracing<T>::value; 70 static const bool value = IsTraceable<T>::value && !IsWeak<T>::value;
67 }; 71 };
68 72
69 // The NeedsToForbidGCOnMove flag is used to make the hash table move 73 // The NeedsToForbidGCOnMove flag is used to make the hash table move
70 // operations safe when GC is enabled: if a move constructor invokes 74 // operations safe when GC is enabled: if a move constructor invokes
71 // an allocation triggering the GC then it should be invoked within GC 75 // an allocation triggering the GC then it should be invoked within GC
72 // forbidden scope. 76 // forbidden scope.
73 template <typename U = void> 77 template <typename U = void>
74 struct NeedsToForbidGCOnMove { 78 struct NeedsToForbidGCOnMove {
75 // TODO(yutak): Consider using of std:::is_trivially_move_constructible 79 // TODO(yutak): Consider using of std:::is_trivially_move_constructible
76 // when it is accessible. 80 // when it is accessible.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 struct KeyValuePairHashTraits : GenericHashTraits<KeyValuePair<typename KeyTrait sArg::TraitType, typename ValueTraitsArg::TraitType>> { 299 struct KeyValuePairHashTraits : GenericHashTraits<KeyValuePair<typename KeyTrait sArg::TraitType, typename ValueTraitsArg::TraitType>> {
296 typedef KeyTraitsArg KeyTraits; 300 typedef KeyTraitsArg KeyTraits;
297 typedef ValueTraitsArg ValueTraits; 301 typedef ValueTraitsArg ValueTraits;
298 typedef KeyValuePair<typename KeyTraits::TraitType, typename ValueTraits::Tr aitType> TraitType; 302 typedef KeyValuePair<typename KeyTraits::TraitType, typename ValueTraits::Tr aitType> TraitType;
299 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueTrait s::EmptyValueType> EmptyValueType; 303 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueTrait s::EmptyValueType> EmptyValueType;
300 304
301 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && ValueTra its::emptyValueIsZero; 305 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && ValueTra its::emptyValueIsZero;
302 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTraits: :EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue(), ValueTraits::emptyValue()); } 306 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTraits: :EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue(), ValueTraits::emptyValue()); }
303 307
304 template <typename U = void> 308 template <typename U = void>
305 struct NeedsTracingLazily { 309 struct IsTraceableInCollection {
306 static const bool value = NeedsTracingTrait<KeyTraits>::value || NeedsTr acingTrait<ValueTraits>::value; 310 static const bool value = IsTraceableInCollectionTrait<KeyTraits>::value || IsTraceableInCollectionTrait<ValueTraits>::value;
307 }; 311 };
308 312
309 template <typename U = void> 313 template <typename U = void>
310 struct NeedsToForbidGCOnMove { 314 struct NeedsToForbidGCOnMove {
311 static const bool value = KeyTraits::template NeedsToForbidGCOnMove<>::v alue || ValueTraits::template NeedsToForbidGCOnMove<>::value; 315 static const bool value = KeyTraits::template NeedsToForbidGCOnMove<>::v alue || ValueTraits::template NeedsToForbidGCOnMove<>::value;
312 }; 316 };
313 317
314 static const WeakHandlingFlag weakHandlingFlag = (KeyTraits::weakHandlingFla g == WeakHandlingInCollections || ValueTraits::weakHandlingFlag == WeakHandlingI nCollections) ? WeakHandlingInCollections : NoWeakHandlingInCollections; 318 static const WeakHandlingFlag weakHandlingFlag = (KeyTraits::weakHandlingFla g == WeakHandlingInCollections || ValueTraits::weakHandlingFlag == WeakHandlingI nCollections) ? WeakHandlingInCollections : NoWeakHandlingInCollections;
315 319
316 static const unsigned minimumTableSize = KeyTraits::minimumTableSize; 320 static const unsigned minimumTableSize = KeyTraits::minimumTableSize;
(...skipping 28 matching lines...) Expand all
345 struct TraceInCollectionTrait; 349 struct TraceInCollectionTrait;
346 350
347 } // namespace WTF 351 } // namespace WTF
348 352
349 using WTF::HashTraits; 353 using WTF::HashTraits;
350 using WTF::PairHashTraits; 354 using WTF::PairHashTraits;
351 using WTF::NullableHashTraits; 355 using WTF::NullableHashTraits;
352 using WTF::SimpleClassHashTraits; 356 using WTF::SimpleClassHashTraits;
353 357
354 #endif // WTF_HashTraits_h 358 #endif // WTF_HashTraits_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashTable.h ('k') | third_party/WebKit/Source/wtf/LinkedHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698