Changeset 123667 in webkit for trunk/Source/JavaScriptCore/tools


Ignore:
Timestamp:
Jul 25, 2012, 3:15:05 PM (13 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Create a specialized pair for use in HashMap iterators
https://bugs.webkit.org/show_bug.cgi?id=92137

Reviewed by Ryosuke Niwa.

Update a couple of sites that relied on the fact that "contents" of iterators were
std::pairs.

  • profiler/Profile.cpp:

(JSC): This code kept a vector of the pairs that were the "contents" of the iterators. This
is changed to use a KeyValuePair. We make use HashCount's ValueType (which represents only
the key) to get the proper key parameter for KeyValuePair.

  • tools/ProfileTreeNode.h:

(ProfileTreeNode): Use HashMap::ValueType to declare the type of the contents of the hash
instead of declaring it manually. This will make use of the new KeyValuePair.

Source/WebKit2: Create a specialized struct for use in HashMap iterators
https://bugs.webkit.org/show_bug.cgi?id=92137

Reviewed by Ryosuke Niwa.

  • Platform/CoreIPC/ArgumentCoders.h: Add encode/decode for KeyValuePair.

Source/WTF: Create a specialized pair for use in HashMap iterators
https://bugs.webkit.org/show_bug.cgi?id=92137

Reviewed by Ryosuke Niwa.

The type used for internal storage in HashMap is exposed in its interface as iterator
"contents". Currently HashMap uses std::pair<>, which this patch replaces with
KeyValuePair.

Having this specialized structure will allow us to customize the members to be called
key/value, improving readability in code using HashMap iterators. They are still called
first/second to separate this change from the mechanical change of updating callsites.

  • wtf/HashIterators.h:

(HashTableConstKeysIterator):
(HashTableConstValuesIterator):
(HashTableKeysIterator):
(HashTableValuesIterator):
Use KeyValuePair instead of std::pair when defining the iterators.

  • wtf/HashMap.h:

(WTF):
(WTF::KeyValuePairKeyExtractor::extract):
(HashMap):
Remove PairFirstExtractor. Add and use the KeyValuePair corresponding extractor.

(WTF::HashMapValueTraits::isEmptyValue): Use KeyValuePairHashTraits for HashMaps.
(WTF::HashMapTranslator::translate):
(WTF::HashMapTranslatorAdapter::translate):
The traits of the mapped value is now called ValueTraits instead of SecondTraits.

  • wtf/HashTable.h:

(WTF::hashTableSwap): Add specialization for swapping KeyValuePairs.
(WTF): Remove now unneeded specialization for std::pairs.

  • wtf/HashTraits.h:

(KeyValuePair):
(WTF::KeyValuePair::KeyValuePair):
(WTF):
Specialized pair. In the future difference from pair should be the member names.

(KeyValuePairHashTraits):
(WTF::KeyValuePairHashTraits::emptyValue):
(WTF::KeyValuePairHashTraits::constructDeletedValue):
(WTF::KeyValuePairHashTraits::isDeletedValue):
These traits are analogous to PairHashTraits but for KeyValuePair.

  • wtf/RefPtrHashMap.h: Use KeyValuePairHashTraits.
File:
1 edited

Legend:

Unmodified
Added
Removed
Note: See TracChangeset for help on using the changeset viewer.