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

Unified Diff: Source/wtf/HashTable.h

Issue 167123002: Simpler return value from HashTable::add()/HashMap::add() and others (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/HashMap.h ('k') | Source/wtf/InstanceCounter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashTable.h
diff --git a/Source/wtf/HashTable.h b/Source/wtf/HashTable.h
index 98f9e9c0a09010b15fb50131ebe6f24121d61df5..7692c3071a99a1c08969a34fe7b3d36b54bf0782 100644
--- a/Source/wtf/HashTable.h
+++ b/Source/wtf/HashTable.h
@@ -205,9 +205,9 @@ namespace WTF {
template<typename T, typename U, typename V> static void translate(T& location, const U&, const V& value) { location = value; }
};
- template<typename IteratorType> struct HashTableAddResult {
- HashTableAddResult(IteratorType iter, bool isNewEntry) : iterator(iter), isNewEntry(isNewEntry) { }
- IteratorType iterator;
+ template<typename ValueType> struct HashTableAddResult {
+ HashTableAddResult(ValueType* storedValue, bool isNewEntry) : storedValue(storedValue), isNewEntry(isNewEntry) { }
+ ValueType* storedValue;
bool isNewEntry;
};
@@ -230,7 +230,7 @@ namespace WTF {
typedef Value ValueType;
typedef typename Traits::PeekInType ValuePeekInType;
typedef IdentityHashTranslator<HashFunctions> IdentityTranslatorType;
- typedef HashTableAddResult<iterator> AddResult;
+ typedef HashTableAddResult<ValueType> AddResult;
#if DUMP_HASHTABLE_STATS_PER_TABLE
struct Stats {
@@ -687,7 +687,7 @@ namespace WTF {
break;
if (HashTranslator::equal(Extractor::extract(*entry), key))
- return AddResult(makeKnownGoodIterator(entry), false);
+ return AddResult(entry, false);
if (isDeletedBucket(*entry))
deletedEntry = entry;
@@ -698,7 +698,7 @@ namespace WTF {
if (isDeletedBucket(*entry))
deletedEntry = entry;
else if (HashTranslator::equal(Extractor::extract(*entry), key))
- return AddResult(makeKnownGoodIterator(entry), false);
+ return AddResult(entry, false);
}
#if DUMP_HASHTABLE_STATS
++probeCount;
@@ -731,12 +731,14 @@ namespace WTF {
// follow a pivot entry and return the new position.
typename WTF::RemoveReference<KeyPassInType>::Type enteredKey = Extractor::extract(*entry);
expand();
- AddResult result(find(enteredKey), true);
- ASSERT(result.iterator != end());
+ iterator findResult = find(enteredKey);
+ ASSERT(findResult != end());
+ ValueType* resultValue = findResult.get();
+ AddResult result(resultValue, true);
return result;
}
- return AddResult(makeKnownGoodIterator(entry), true);
+ return AddResult(entry, true);
}
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
@@ -753,7 +755,7 @@ namespace WTF {
unsigned h = lookupResult.second;
if (found)
- return AddResult(makeKnownGoodIterator(entry), false);
+ return AddResult(entry, false);
if (isDeletedBucket(*entry)) {
initializeBucket(*entry);
@@ -768,12 +770,14 @@ namespace WTF {
// follow a pivot entry and return the new position.
typename WTF::RemoveReference<KeyPassInType>::Type enteredKey = Extractor::extract(*entry);
expand();
- AddResult result(find(enteredKey), true);
- ASSERT(result.iterator != end());
+ iterator findResult = find(enteredKey);
+ ASSERT(findResult != end());
+ ValueType* resultValue = findResult.get();
+ AddResult result(resultValue, true);
return result;
}
- return AddResult(makeKnownGoodIterator(entry), true);
+ return AddResult(entry, true);
}
template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits, typename Allocator>
« no previous file with comments | « Source/wtf/HashMap.h ('k') | Source/wtf/InstanceCounter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698