HashMap<>::add should return a more descriptive object
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 18:48:23 +0000 (18:48 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2012 18:48:23 +0000 (18:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71063

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

Update code to use AddResult instead of a pair. Note that since WeakGCMap wraps
the iterator type, there's a need for its own AddResult type -- instantiated from
HashTableAddResult template class.

* API/JSCallbackObject.h:
(JSC::JSCallbackObjectData::JSPrivatePropertyMap::setPrivateProperty):
* API/JSClassRef.cpp:
(OpaqueJSClass::contextData):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::addVar):
(JSC::BytecodeGenerator::addGlobalVar):
(JSC::BytecodeGenerator::addConstant):
(JSC::BytecodeGenerator::addConstantValue):
(JSC::BytecodeGenerator::emitLoad):
(JSC::BytecodeGenerator::addStringConstant):
(JSC::BytecodeGenerator::emitLazyNewFunction):
* bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
* debugger/Debugger.cpp:
* dfg/DFGAssemblyHelpers.cpp:
(JSC::DFG::AssemblyHelpers::decodedCodeMapFor):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::cellConstant):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
* jit/JITStubs.cpp:
(JSC::JITThunks::ctiStub):
(JSC::JITThunks::hostFunctionStub):
* parser/Parser.cpp:
(JSC::::parseStrictObjectLiteral):
* parser/Parser.h:
(JSC::Scope::declareParameter):
* runtime/Identifier.cpp:
(JSC::Identifier::add):
(JSC::Identifier::add8):
(JSC::Identifier::addSlowCase):
* runtime/Identifier.h:
(JSC::Identifier::add):
(JSC::IdentifierTable::add):
* runtime/JSArray.cpp:
(JSC::SparseArrayValueMap::add):
(JSC::SparseArrayValueMap::put):
(JSC::SparseArrayValueMap::putDirect):
(JSC::JSArray::enterDictionaryMode):
(JSC::JSArray::defineOwnNumericProperty):
* runtime/JSArray.h:
(SparseArrayValueMap):
* runtime/PropertyNameArray.cpp:
(JSC::PropertyNameArray::add):
* runtime/StringRecursionChecker.h:
(JSC::StringRecursionChecker::performCheck):
* runtime/Structure.cpp:
(JSC::StructureTransitionTable::add):
* runtime/WeakGCMap.h:
(WeakGCMap):
(JSC::WeakGCMap::add):
(JSC::WeakGCMap::set):
* tools/ProfileTreeNode.h:
(JSC::ProfileTreeNode::sampleChild):

Source/WebCore:

Update code to use AddResult instead of a pair. No new tests, just a refactoring.

* Modules/webdatabase/SQLTransactionCoordinator.cpp:
(WebCore::SQLTransactionCoordinator::acquireLock):
* Modules/webdatabase/chromium/QuotaTracker.cpp:
(WebCore::QuotaTracker::updateDatabaseSize):
* bindings/js/DOMObjectHashTableMap.h:
(WebCore::DOMObjectHashTableMap::get):
* bindings/js/JSDOMBinding.cpp:
(WebCore::cacheDOMStructure):
* bindings/js/JSDOMBinding.h:
(WebCore::cacheWrapper):
* bindings/js/JSDOMGlobalObject.h:
(WebCore::getDOMConstructor):
* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::addListener):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::setBreakpoint):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::startObjectInternal):
(WebCore::CloneSerializer::write):
* bindings/v8/NPV8Object.cpp:
(WebCore::npCreateV8ScriptObject):
* bridge/IdentifierRep.cpp:
(WebCore::IdentifierRep::get):
* bridge/NP_jsobject.cpp:
(ObjectMap::add):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::logUnimplementedPropertyID):
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::getFontData):
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
(WebCore::CSSFontSelector::getFontData):
* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::getFontData):
* css/CSSStyleApplyProperty.cpp:
(WebCore::ApplyPropertyCounter::applyInheritValue):
(WebCore::ApplyPropertyCounter::applyValue):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::appendAuthorStylesheets):
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::createIdentifierValue):
(WebCore::CSSValuePool::createColorValue):
(WebCore::CSSValuePool::createValue):
(WebCore::CSSValuePool::createFontFamilyValue):
(WebCore::CSSValuePool::createFontFaceValue):
* dom/CheckedRadioButtons.cpp:
(WebCore::RadioButtonGroup::add):
(WebCore::CheckedRadioButtons::addButton):
* dom/ChildListMutationScope.cpp:
(WebCore::ChildListMutationScope::MutationAccumulationRouter::incrementScopingLevel):
* dom/Document.cpp:
(WebCore::Document::windowNamedItems):
(WebCore::Document::documentNamedItems):
(WebCore::Document::getCSSCanvasElement):
(WebCore::Document::getItems):
* dom/DocumentEventQueue.cpp:
(WebCore::DocumentEventQueue::enqueueEvent):
(WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent):
(WebCore::DocumentEventQueue::pendingEventTimerFired):
* dom/DocumentOrderedMap.cpp:
(WebCore::DocumentOrderedMap::add):
* dom/EventListenerMap.cpp:
(WebCore::EventListenerMap::add):
* dom/Node.cpp:
(WebCore::Node::dumpStatistics):
(WebCore::Node::getElementsByTagName):
(WebCore::Node::getElementsByTagNameNS):
(WebCore::Node::getElementsByName):
(WebCore::Node::getElementsByClassName):
(WebCore::Node::collectMatchingObserversForMutation):
* dom/QualifiedName.cpp:
(WebCore::QualifiedName::init):
* dom/SpaceSplitString.cpp:
(WebCore::SpaceSplitStringData::create):
* dom/StyledElement.cpp:
(WebCore::StyledElement::updateAttributeStyle):
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::append):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::diff):
* inspector/InspectorCSSAgent.cpp:
(WebCore::SelectorProfile::commitSelector):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::performSearch):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::resolveBreakpoint):
* inspector/InspectorValues.h:
(WebCore::InspectorObject::setValue):
(WebCore::InspectorObject::setObject):
(WebCore::InspectorObject::setArray):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::addEntry):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::findOrCreateCacheGroup):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleTouchEvent):
* page/PageGroup.cpp:
(WebCore::PageGroup::pageGroup):
(WebCore::PageGroup::addVisitedLink):
(WebCore::PageGroup::addUserScriptToWorld):
(WebCore::PageGroup::addUserStyleSheetToWorld):
* page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::addOriginAccessWhitelistEntry):
* page/TouchAdjustment.cpp:
(WebCore::TouchAdjustment::compileSubtargetList):
* platform/cf/BinaryPropertyList.cpp:
(WebCore::BinaryPropertyListPlan::writeInteger):
(WebCore::BinaryPropertyListPlan::writeString):
(WebCore::BinaryPropertyListPlan::writeIntegerArray):
* platform/graphics/blackberry/LayerTiler.cpp:
(WebCore::LayerTiler::addTileJob):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::findOrMakeClone):
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::revalidateTiles):
* platform/graphics/ca/win/LayerChangesFlusher.cpp:
(WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon):
* platform/graphics/chromium/FontUtilsChromiumWin.cpp:
(WebCore::getDerivedFontData):
* platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
(WebCore::CCLayerAnimationController::startAnimationsWaitingForTargetAvailability):
* platform/graphics/mac/ComplexTextControllerATSUI.cpp:
(WebCore::initializeATSUStyle):
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::SimpleFontData::getCFStringAttributes):
* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::SimpleFontData::canRenderCombiningCharacterSequence):
* platform/graphics/wince/FontPlatformData.cpp:
(WebCore::FixedSizeFontData::create):
* platform/gtk/RenderThemeGtk3.cpp:
(WebCore::getStyleContext):
* platform/mac/ThreadCheck.mm:
(WebCoreReportThreadViolation):
* platform/network/HTTPHeaderMap.cpp:
(WebCore::HTTPHeaderMap::add):
* platform/network/HTTPHeaderMap.h:
(HTTPHeaderMap):
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::addHTTPHeaderField):
* plugins/PluginDatabase.cpp:
(WebCore::PluginDatabase::add):
(WebCore::PluginDatabase::loadPersistentMetadataCache):
* plugins/win/PluginDatabaseWin.cpp:
(WebCore::PluginDatabase::getPluginPathsInDirectories):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::addPercentHeightDescendant):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun):
* rendering/RenderNamedFlowThread.cpp:
(WebCore::RenderNamedFlowThread::addDependencyOnFlowThread):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::setRenderBoxRegionInfo):
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::applyResource):
* storage/StorageMap.cpp:
(WebCore::StorageMap::setItem):
(WebCore::StorageMap::importItem):
* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::addPendingResource):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::setRequestHeaderInternal):
* xml/XPathFunctions.cpp:
(WebCore::XPath::FunId::evaluate):
* xml/XPathPath.cpp:
(WebCore::XPath::LocationPath::evaluate):
* xml/XPathPredicate.cpp:
(WebCore::XPath::Union::evaluate):

Source/WebKit/chromium:

Update code to use AddResult instead of a pair.

* src/WebHTTPLoadInfo.cpp:
(WebKit::addHeader):
* src/WebURLResponse.cpp:
(WebKit::WebURLResponse::addHTTPHeaderField):

Source/WebKit/mac:

Update code to use AddResult instead of a pair.

* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::hostForPlugin):
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):
* WebCoreSupport/WebNotificationClient.mm:
(WebNotificationClient::show):

Source/WebKit/win:

Update code to use AddResult instead of a pair.

* WebKitCOMAPI.cpp:
(classFactory):

Source/WebKit2:

Update code to use AddResult instead of a pair.

* Platform/CoreIPC/ArgumentCoders.h:
* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::SyncMessageState::getOrCreate):
* Shared/MutableDictionary.cpp:
(WebKit::MutableDictionary::add):
(WebKit::MutableDictionary::set):
* Shared/UserMessageCoders.h:
(WebKit::UserMessageDecoder::baseDecode):
* Shared/mac/CommandLineMac.cpp:
(WebKit::CommandLine::parse):
* UIProcess/API/mac/WKPrintingView.mm:
(pageDidDrawToPDF):
* UIProcess/API/mac/WKView.mm:
(-[WKView validateUserInterfaceItem:]):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addBackForwardItem):
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::getOrCreate):
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::getOrCreate):
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::show):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::createWebPage):
(WebKit::WebProcess::webPageGroup):

Source/WTF:

Make HashTable<>::add() and derivate functions return an AddResult struct instead
of a pair. This struct contains contains 'iterator' and 'isNewEntry' members, that are
more readable at callsites than previous 'first' and 'second'.

* wtf/HashCountedSet.h:
(HashCountedSet):
(WTF::::add):
* wtf/HashMap.h:
(HashMap):
(WTF):
(WTF::::set):
* wtf/HashSet.h:
(HashSet):
(WTF::::add):
(WTF):
* wtf/HashTable.h:
(WTF::HashTableAddResult::HashTableAddResult):
(HashTableAddResult):
(WTF):
(HashTable):
(WTF::HashTable::add):
(WTF::::add):
(WTF::::addPassingHashCode):
* wtf/ListHashSet.h:
(ListHashSet):
(WTF::::add):
(WTF::::insertBefore):
* wtf/RefPtrHashMap.h:
(WTF):
(WTF::::set):
* wtf/Spectrum.h:
(WTF::Spectrum::add):
* wtf/WTFThreadData.cpp:
(JSC::IdentifierTable::add):
* wtf/WTFThreadData.h:
(IdentifierTable):
* wtf/text/AtomicString.cpp:
(WTF::addToStringTable):
(WTF::AtomicString::addSlowCase):

Tools:

Update code to use AddResult instead of a pair.

* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::evaluateScriptInIsolatedWorld):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::evaluateScriptInIsolatedWorld):
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::evaluateScriptInIsolatedWorld):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112555 268f45cc-cd09-0410-ab3c-d52691b4dbfc

129 files changed:
Source/JavaScriptCore/API/JSCallbackObject.h
Source/JavaScriptCore/API/JSClassRef.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/dfg/DFGAssemblyHelpers.cpp
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h
Source/JavaScriptCore/runtime/Identifier.cpp
Source/JavaScriptCore/runtime/Identifier.h
Source/JavaScriptCore/runtime/JSArray.cpp
Source/JavaScriptCore/runtime/JSArray.h
Source/JavaScriptCore/runtime/PropertyNameArray.cpp
Source/JavaScriptCore/runtime/StringRecursionChecker.h
Source/JavaScriptCore/runtime/Structure.cpp
Source/JavaScriptCore/runtime/WeakGCMap.h
Source/JavaScriptCore/tools/ProfileTreeNode.h
Source/WTF/ChangeLog
Source/WTF/wtf/HashCountedSet.h
Source/WTF/wtf/HashMap.h
Source/WTF/wtf/HashSet.h
Source/WTF/wtf/HashTable.h
Source/WTF/wtf/ListHashSet.h
Source/WTF/wtf/RefPtrHashMap.h
Source/WTF/wtf/Spectrum.h
Source/WTF/wtf/WTFThreadData.cpp
Source/WTF/wtf/WTFThreadData.h
Source/WTF/wtf/text/AtomicString.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp
Source/WebCore/Modules/webdatabase/chromium/QuotaTracker.cpp
Source/WebCore/bindings/js/DOMObjectHashTableMap.h
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMGlobalObject.h
Source/WebCore/bindings/js/PageScriptDebugServer.cpp
Source/WebCore/bindings/js/ScriptDebugServer.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/v8/NPV8Object.cpp
Source/WebCore/bridge/IdentifierRep.cpp
Source/WebCore/bridge/NP_jsobject.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSFontFaceSource.cpp
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSSegmentedFontFace.cpp
Source/WebCore/css/CSSStyleApplyProperty.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValuePool.cpp
Source/WebCore/dom/CheckedRadioButtons.cpp
Source/WebCore/dom/ChildListMutationScope.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentEventQueue.cpp
Source/WebCore/dom/DocumentOrderedMap.cpp
Source/WebCore/dom/EventListenerMap.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/QualifiedName.cpp
Source/WebCore/dom/SpaceSplitString.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/html/HTMLCollection.cpp
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorValues.h
Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/SecurityPolicy.cpp
Source/WebCore/page/TouchAdjustment.cpp
Source/WebCore/platform/cf/BinaryPropertyList.cpp
Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/mac/TileCache.mm
Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp
Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerAnimationController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp
Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
Source/WebCore/platform/graphics/wince/FontPlatformData.cpp
Source/WebCore/platform/gtk/RenderThemeGtk3.cpp
Source/WebCore/platform/mac/ThreadCheck.mm
Source/WebCore/platform/network/HTTPHeaderMap.cpp
Source/WebCore/platform/network/HTTPHeaderMap.h
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/plugins/PluginDatabase.cpp
Source/WebCore/plugins/win/PluginDatabaseWin.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderNamedFlowThread.cpp
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/storage/StorageMap.cpp
Source/WebCore/svg/SVGDocumentExtensions.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XPathFunctions.cpp
Source/WebCore/xml/XPathPath.cpp
Source/WebCore/xml/XPathPredicate.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebHTTPLoadInfo.cpp
Source/WebKit/chromium/src/WebURLResponse.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKitCOMAPI.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h
Source/WebKit2/Platform/CoreIPC/Connection.cpp
Source/WebKit2/Shared/MutableDictionary.cpp
Source/WebKit2/Shared/UserMessageCoders.h
Source/WebKit2/Shared/mac/CommandLineMac.cpp
Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/LayoutTestControllerMac.mm
Tools/DumpRenderTree/win/LayoutTestControllerWin.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp

index 613e538..9aca0c7 100644 (file)
@@ -89,7 +89,7 @@ struct JSCallbackObjectData : WeakHandleOwner {
         void setPrivateProperty(JSGlobalData& globalData, JSCell* owner, const Identifier& propertyName, JSValue value)
         {
             WriteBarrier<Unknown> empty;
-            m_propertyMap.add(propertyName.impl(), empty).first->second.set(globalData, owner, value);
+            m_propertyMap.add(propertyName.impl(), empty).iterator->second.set(globalData, owner, value);
         }
         
         void deletePrivateProperty(const Identifier& propertyName)
index 5c249ab..13534d0 100644 (file)
@@ -164,7 +164,7 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(JSC::JSGlobalData&, OpaqueJSC
 
 OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec)
 {
-    OwnPtr<OpaqueJSClassContextData>& contextData = exec->globalData().opaqueJSClassData.add(this, nullptr).first->second;
+    OwnPtr<OpaqueJSClassContextData>& contextData = exec->globalData().opaqueJSClassData.add(this, nullptr).iterator->second;
     if (!contextData)
         contextData = adoptPtr(new OpaqueJSClassContextData(exec->globalData(), this));
     return *contextData;
index b704ab2..9094240 100644 (file)
@@ -1,3 +1,69 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair. Note that since WeakGCMap wraps
+        the iterator type, there's a need for its own AddResult type -- instantiated from
+        HashTableAddResult template class.
+
+        * API/JSCallbackObject.h:
+        (JSC::JSCallbackObjectData::JSPrivatePropertyMap::setPrivateProperty):
+        * API/JSClassRef.cpp:
+        (OpaqueJSClass::contextData):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::addVar):
+        (JSC::BytecodeGenerator::addGlobalVar):
+        (JSC::BytecodeGenerator::addConstant):
+        (JSC::BytecodeGenerator::addConstantValue):
+        (JSC::BytecodeGenerator::emitLoad):
+        (JSC::BytecodeGenerator::addStringConstant):
+        (JSC::BytecodeGenerator::emitLazyNewFunction):
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::PropertyListNode::emitBytecode):
+        * debugger/Debugger.cpp:
+        * dfg/DFGAssemblyHelpers.cpp:
+        (JSC::DFG::AssemblyHelpers::decodedCodeMapFor):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::cellConstant):
+        (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
+        * jit/JITStubs.cpp:
+        (JSC::JITThunks::ctiStub):
+        (JSC::JITThunks::hostFunctionStub):
+        * parser/Parser.cpp:
+        (JSC::::parseStrictObjectLiteral):
+        * parser/Parser.h:
+        (JSC::Scope::declareParameter):
+        * runtime/Identifier.cpp:
+        (JSC::Identifier::add):
+        (JSC::Identifier::add8):
+        (JSC::Identifier::addSlowCase):
+        * runtime/Identifier.h:
+        (JSC::Identifier::add):
+        (JSC::IdentifierTable::add):
+        * runtime/JSArray.cpp:
+        (JSC::SparseArrayValueMap::add):
+        (JSC::SparseArrayValueMap::put):
+        (JSC::SparseArrayValueMap::putDirect):
+        (JSC::JSArray::enterDictionaryMode):
+        (JSC::JSArray::defineOwnNumericProperty):
+        * runtime/JSArray.h:
+        (SparseArrayValueMap):
+        * runtime/PropertyNameArray.cpp:
+        (JSC::PropertyNameArray::add):
+        * runtime/StringRecursionChecker.h:
+        (JSC::StringRecursionChecker::performCheck):
+        * runtime/Structure.cpp:
+        (JSC::StructureTransitionTable::add):
+        * runtime/WeakGCMap.h:
+        (WeakGCMap):
+        (JSC::WeakGCMap::add):
+        (JSC::WeakGCMap::set):
+        * tools/ProfileTreeNode.h:
+        (JSC::ProfileTreeNode::sampleChild):
+
 2012-03-29  Patrick Gansterer  <paroga@webkit.org>
 
         Build fix for !ENABLE(YARR_JIT) after r112454.
index 4a6f465..0f08579 100644 (file)
@@ -200,10 +200,10 @@ bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, Registe
 {
     int index = m_calleeRegisters.size();
     SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0);
-    pair<SymbolTable::iterator, bool> result = symbolTable().add(ident.impl(), newEntry);
+    SymbolTable::AddResult result = symbolTable().add(ident.impl(), newEntry);
 
-    if (!result.second) {
-        r0 = &registerFor(result.first->second.getIndex());
+    if (!result.isNewEntry) {
+        r0 = &registerFor(result.iterator->second.getIndex());
         return false;
     }
 
@@ -215,9 +215,9 @@ int BytecodeGenerator::addGlobalVar(const Identifier& ident, bool isConstant)
 {
     int index = symbolTable().size();
     SymbolTableEntry newEntry(index, isConstant ? ReadOnly : 0);
-    pair<SymbolTable::iterator, bool> result = symbolTable().add(ident.impl(), newEntry);
-    if (!result.second)
-        index = result.first->second.getIndex();
+    SymbolTable::AddResult result = symbolTable().add(ident.impl(), newEntry);
+    if (!result.isNewEntry)
+        index = result.iterator->second.getIndex();
     return index;
 }
 
@@ -968,24 +968,24 @@ PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond
 unsigned BytecodeGenerator::addConstant(const Identifier& ident)
 {
     StringImpl* rep = ident.impl();
-    pair<IdentifierMap::iterator, bool> result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers());
-    if (result.second) // new entry
+    IdentifierMap::AddResult result = m_identifierMap.add(rep, m_codeBlock->numberOfIdentifiers());
+    if (result.isNewEntry)
         m_codeBlock->addIdentifier(Identifier(m_globalData, rep));
 
-    return result.first->second;
+    return result.iterator->second;
 }
 
 RegisterID* BytecodeGenerator::addConstantValue(JSValue v)
 {
     int index = m_nextConstantOffset;
 
-    pair<JSValueMap::iterator, bool> result = m_jsValueMap.add(JSValue::encode(v), m_nextConstantOffset);
-    if (result.second) {
+    JSValueMap::AddResult result = m_jsValueMap.add(JSValue::encode(v), m_nextConstantOffset);
+    if (result.isNewEntry) {
         m_constantPoolRegisters.append(FirstConstantRegisterIndex + m_nextConstantOffset);
         ++m_nextConstantOffset;
         m_codeBlock->addConstant(JSValue(v));
     } else
-        index = result.first->second;
+        index = result.iterator->second;
 
     return &m_constantPoolRegisters[index];
 }
@@ -1132,7 +1132,7 @@ RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, double number)
     // work correctly with NaN as a key.
     if (isnan(number) || number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number))
         return emitLoad(dst, jsNumber(number));
-    JSValue& valueInMap = m_numberMap.add(number, JSValue()).first->second;
+    JSValue& valueInMap = m_numberMap.add(number, JSValue()).iterator->second;
     if (!valueInMap)
         valueInMap = jsNumber(number);
     return emitLoad(dst, valueInMap);
@@ -1140,7 +1140,7 @@ RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, double number)
 
 RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, const Identifier& identifier)
 {
-    JSString*& stringInMap = m_stringMap.add(identifier.impl(), 0).first->second;
+    JSString*& stringInMap = m_stringMap.add(identifier.impl(), 0).iterator->second;
     if (!stringInMap)
         stringInMap = jsOwnedString(globalData(), identifier.ustring());
     return emitLoad(dst, JSValue(stringInMap));
@@ -1648,7 +1648,7 @@ unsigned BytecodeGenerator::addConstantBuffer(unsigned length)
 
 JSString* BytecodeGenerator::addStringConstant(const Identifier& identifier)
 {
-    JSString*& stringInMap = m_stringMap.add(identifier.impl(), 0).first->second;
+    JSString*& stringInMap = m_stringMap.add(identifier.impl(), 0).iterator->second;
     if (!stringInMap) {
         stringInMap = jsString(globalData(), identifier.ustring());
         addConstantValue(stringInMap);
@@ -1718,10 +1718,10 @@ RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode
 
 RegisterID* BytecodeGenerator::emitLazyNewFunction(RegisterID* dst, FunctionBodyNode* function)
 {
-    std::pair<FunctionOffsetMap::iterator, bool> ptr = m_functionOffsets.add(function, 0);
-    if (ptr.second)
-        ptr.first->second = m_codeBlock->addFunctionDecl(makeFunction(m_globalData, function));
-    return emitNewFunctionInternal(dst, ptr.first->second, true);
+    FunctionOffsetMap::AddResult ptr = m_functionOffsets.add(function, 0);
+    if (ptr.isNewEntry)
+        ptr.iterator->second = m_codeBlock->addFunctionDecl(makeFunction(m_globalData, function));
+    return emitNewFunctionInternal(dst, ptr.iterator->second, true);
 }
 
 RegisterID* BytecodeGenerator::emitNewFunctionInternal(RegisterID* dst, unsigned index, bool doNullCheck)
index bb95caf..cd9de22 100644 (file)
@@ -256,9 +256,9 @@ RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator& generator, Registe
                 continue;
 
             GetterSetterPair pair(node, static_cast<PropertyNode*>(0));
-            std::pair<GetterSetterMap::iterator, bool> result = map.add(node->name().impl(), pair);
-            if (!result.second)
-                result.first->second.second = node;
+            GetterSetterMap::AddResult result = map.add(node->name().impl(), pair);
+            if (!result.isNewEntry)
+                result.iterator->second.second = node;
         }
 
         // Iterate over the remaining properties in the list.
index 441c9ae..ede8a9b 100644 (file)
@@ -75,7 +75,7 @@ inline void Recompiler::operator()(JSCell* cell)
 
     // Check if the function is already in the set - if so,
     // we've already retranslated it, nothing to do here.
-    if (!m_functionExecutables.add(executable).second)
+    if (!m_functionExecutables.add(executable).isNewEntry)
         return;
 
     ExecState* exec = function->scope()->globalObject->JSGlobalObject::globalExec();
index 969101e..ac2c3db 100644 (file)
@@ -38,12 +38,12 @@ Vector<BytecodeAndMachineOffset>& AssemblyHelpers::decodedCodeMapFor(CodeBlock*
     ASSERT(codeBlock->getJITType() == JITCode::BaselineJIT);
     ASSERT(codeBlock->jitCodeMap());
     
-    std::pair<HashMap<CodeBlock*, Vector<BytecodeAndMachineOffset> >::iterator, bool> result = m_decodedCodeMaps.add(codeBlock, Vector<BytecodeAndMachineOffset>());
+    HashMap<CodeBlock*, Vector<BytecodeAndMachineOffset> >::AddResult result = m_decodedCodeMaps.add(codeBlock, Vector<BytecodeAndMachineOffset>());
     
-    if (result.second)
-        codeBlock->jitCodeMap()->decode(result.first->second);
+    if (result.isNewEntry)
+        codeBlock->jitCodeMap()->decode(result.iterator->second);
     
-    return result.first->second;
+    return result.iterator->second;
 }
 
 #if ENABLE(SAMPLING_FLAGS)
index 9285056..f0da6cc 100644 (file)
@@ -551,11 +551,11 @@ private:
     
     NodeIndex cellConstant(JSCell* cell)
     {
-        pair<HashMap<JSCell*, NodeIndex>::iterator, bool> iter = m_cellConstantNodes.add(cell, NoNode);
-        if (iter.second)
-            iter.first->second = addToGraph(WeakJSConstant, OpInfo(cell));
+        HashMap<JSCell*, NodeIndex>::AddResult result = m_cellConstantNodes.add(cell, NoNode);
+        if (result.isNewEntry)
+            result.iterator->second = addToGraph(WeakJSConstant, OpInfo(cell));
         
-        return iter.first->second;
+        return result.iterator->second;
     }
     
     CodeOrigin currentCodeOrigin()
@@ -2595,10 +2595,10 @@ ByteCodeParser::InlineStackEntry::InlineStackEntry(ByteCodeParser* byteCodeParse
 
         for (size_t i = 0; i < codeBlock->numberOfIdentifiers(); ++i) {
             StringImpl* rep = codeBlock->identifier(i).impl();
-            pair<IdentifierMap::iterator, bool> result = byteCodeParser->m_identifierMap.add(rep, byteCodeParser->m_codeBlock->numberOfIdentifiers());
-            if (result.second)
+            IdentifierMap::AddResult result = byteCodeParser->m_identifierMap.add(rep, byteCodeParser->m_codeBlock->numberOfIdentifiers());
+            if (result.isNewEntry)
                 byteCodeParser->m_codeBlock->addIdentifier(Identifier(byteCodeParser->m_globalData, rep));
-            m_identifierRemap[i] = result.first->second;
+            m_identifierRemap[i] = result.iterator->second;
         }
         for (size_t i = 0; i < codeBlock->numberOfConstantRegisters(); ++i) {
             JSValue value = codeBlock->getConstant(i + FirstConstantRegisterIndex);
@@ -2611,12 +2611,12 @@ ByteCodeParser::InlineStackEntry::InlineStackEntry(ByteCodeParser* byteCodeParse
                 m_constantRemap[i] = byteCodeParser->m_emptyJSValueIndex;
                 continue;
             }
-            pair<JSValueMap::iterator, bool> result = byteCodeParser->m_jsValueMap.add(JSValue::encode(value), byteCodeParser->m_codeBlock->numberOfConstantRegisters() + FirstConstantRegisterIndex);
-            if (result.second) {
+            JSValueMap::AddResult result = byteCodeParser->m_jsValueMap.add(JSValue::encode(value), byteCodeParser->m_codeBlock->numberOfConstantRegisters() + FirstConstantRegisterIndex);
+            if (result.isNewEntry) {
                 byteCodeParser->m_codeBlock->addConstant(value);
                 byteCodeParser->m_constants.append(ConstantRecord());
             }
-            m_constantRemap[i] = result.first->second;
+            m_constantRemap[i] = result.iterator->second;
         }
         
         m_callsiteBlockHeadNeedsLinking = true;
index 9ae32c4..82f6df7 100644 (file)
@@ -3558,24 +3558,24 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, to_object)
 
 MacroAssemblerCodeRef JITThunks::ctiStub(JSGlobalData* globalData, ThunkGenerator generator)
 {
-    std::pair<CTIStubMap::iterator, bool> entry = m_ctiStubMap.add(generator, MacroAssemblerCodeRef());
-    if (entry.second)
-        entry.first->second = generator(globalData);
-    return entry.first->second;
+    CTIStubMap::AddResult entry = m_ctiStubMap.add(generator, MacroAssemblerCodeRef());
+    if (entry.isNewEntry)
+        entry.iterator->second = generator(globalData);
+    return entry.iterator->second;
 }
 
 NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, NativeFunction constructor)
 {
-    std::pair<HostFunctionStubMap::iterator, bool> result = m_hostFunctionStubMap->add(function, PassWeak<NativeExecutable>());
-    if (!result.first->second)
-        result.first->second = PassWeak<NativeExecutable>(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), constructor, NoIntrinsic));
-    return result.first->second.get();
+    HostFunctionStubMap::AddResult result = m_hostFunctionStubMap->add(function, PassWeak<NativeExecutable>());
+    if (!result.iterator->second)
+        result.iterator->second = PassWeak<NativeExecutable>(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, function), function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), constructor, NoIntrinsic));
+    return result.iterator->second.get();
 }
 
 NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator, Intrinsic intrinsic)
 {
-    std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, PassWeak<NativeExecutable>());
-    if (!*entry.first->second) {
+    HostFunctionStubMap::AddResult entry = m_hostFunctionStubMap->add(function, PassWeak<NativeExecutable>());
+    if (!*entry.iterator->second) {
         MacroAssemblerCodeRef code;
         if (generator) {
             if (globalData->canUseJIT())
@@ -3584,9 +3584,9 @@ NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFu
                 code = MacroAssemblerCodeRef();
         } else
             code = JIT::compileCTINativeCall(globalData, function);
-        entry.first->second = PassWeak<NativeExecutable>(*globalData, NativeExecutable::create(*globalData, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor, intrinsic));
+        entry.iterator->second = PassWeak<NativeExecutable>(*globalData, NativeExecutable::create(*globalData, code, function, MacroAssemblerCodeRef::createSelfManagedCodeRef(ctiNativeConstruct()), callHostFunctionAsConstructor, intrinsic));
     }
-    return entry.first->second.get();
+    return entry.iterator->second.get();
 }
 
 void JITThunks::clearHostFunctionStubs()
index f58847f..6943977 100644 (file)
@@ -1323,12 +1323,12 @@ template <class TreeBuilder> TreeExpression Parser<LexerType>::parseStrictObject
         property = parseProperty<true>(context);
         failIfFalse(property);
         if (!m_syntaxAlreadyValidated) {
-            std::pair<ObjectValidationMap::iterator, bool> propertyEntryIter = objectValidator.add(context.getName(property).impl(), context.getType(property));
-            if (!propertyEntryIter.second) {
-                failIfTrue(propertyEntryIter.first->second == PropertyNode::Constant);
+            ObjectValidationMap::AddResult propertyEntry = objectValidator.add(context.getName(property).impl(), context.getType(property));
+            if (!propertyEntry.isNewEntry) {
+                failIfTrue(propertyEntry.iterator->second == PropertyNode::Constant);
                 failIfTrue(context.getType(property) == PropertyNode::Constant);
-                failIfTrue(context.getType(property) & propertyEntryIter.first->second);
-                propertyEntryIter.first->second |= context.getType(property);
+                failIfTrue(context.getType(property) & propertyEntry.iterator->second);
+                propertyEntry.iterator->second |= context.getType(property);
             }
         }
         tail = context.createPropertyList(m_lexer->lastLineNumber(), property, tail);
index 7513d1f..68a693a 100644 (file)
@@ -223,7 +223,7 @@ struct Scope {
     bool declareParameter(const Identifier* ident)
     {
         bool isArguments = m_globalData->propertyNames->arguments == *ident;
-        bool isValidStrictMode = m_declaredVariables.add(ident->ustring().impl()).second && m_globalData->propertyNames->eval != *ident && !isArguments;
+        bool isValidStrictMode = m_declaredVariables.add(ident->ustring().impl()).isNewEntry && m_globalData->propertyNames->eval != *ident && !isArguments;
         m_isValidStrictMode = m_isValidStrictMode && isValidStrictMode;
         if (isArguments)
             setFlags(ShadowsArgumentsFlag);
index fbc5787..182bcc4 100644 (file)
@@ -110,11 +110,11 @@ PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const char* c)
     if (iter != literalIdentifierTable.end())
         return iter->second;
 
-    pair<HashSet<StringImpl*>::iterator, bool> addResult = identifierTable.add<const LChar*, IdentifierCStringTranslator>(reinterpret_cast<const LChar*>(c));
+    HashSet<StringImpl*>::AddResult addResult = identifierTable.add<const LChar*, IdentifierCStringTranslator>(reinterpret_cast<const LChar*>(c));
 
     // If the string is newly-translated, then we need to adopt it.
     // The boolean in the pair tells us if that is so.
-    RefPtr<StringImpl> addedString = addResult.second ? adoptRef(*addResult.first) : *addResult.first;
+    RefPtr<StringImpl> addedString = addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
 
     literalIdentifierTable.add(c, addedString.get());
 
@@ -138,11 +138,11 @@ PassRefPtr<StringImpl> Identifier::add8(JSGlobalData* globalData, const UChar* s
     if (!length)
         return StringImpl::empty();
     CharBuffer<UChar> buf = {s, length}; 
-    pair<HashSet<StringImpl*>::iterator, bool> addResult = globalData->identifierTable->add<CharBuffer<UChar>, IdentifierLCharFromUCharTranslator >(buf);
+    HashSet<StringImpl*>::AddResult addResult = globalData->identifierTable->add<CharBuffer<UChar>, IdentifierLCharFromUCharTranslator >(buf);
     
     // If the string is newly-translated, then we need to adopt it.
     // The boolean in the pair tells us if that is so.
-    return addResult.second ? adoptRef(*addResult.first) : *addResult.first;
+    return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
 }
 
 template <typename CharType>
@@ -210,7 +210,7 @@ PassRefPtr<StringImpl> Identifier::addSlowCase(JSGlobalData* globalData, StringI
                 return r;
     }
 
-    return *globalData->identifierTable->add(r).first;
+    return *globalData->identifierTable->add(r).iterator;
 }
 
 PassRefPtr<StringImpl> Identifier::addSlowCase(ExecState* exec, StringImpl* r)
index b9e5a18..1496087 100644 (file)
@@ -178,11 +178,11 @@ namespace JSC {
         if (!length)
             return StringImpl::empty();
         CharBuffer<T> buf = {s, length}; 
-        pair<HashSet<StringImpl*>::iterator, bool> addResult = globalData->identifierTable->add<CharBuffer<T>, IdentifierCharBufferTranslator<T> >(buf);
+        HashSet<StringImpl*>::AddResult addResult = globalData->identifierTable->add<CharBuffer<T>, IdentifierCharBufferTranslator<T> >(buf);
         
         // If the string is newly-translated, then we need to adopt it.
         // The boolean in the pair tells us if that is so.
-        return addResult.second ? adoptRef(*addResult.first) : *addResult.first;
+        return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
     }
 
     inline bool operator==(const Identifier& a, const Identifier& b)
@@ -246,10 +246,10 @@ namespace JSC {
     typedef HashMap<RefPtr<StringImpl>, int, IdentifierRepHash, HashTraits<RefPtr<StringImpl> >, IdentifierMapIndexHashTraits> IdentifierMap;
 
     template<typename U, typename V>
-    std::pair<HashSet<StringImpl*>::iterator, bool> IdentifierTable::add(U value)
+    HashSet<StringImpl*>::AddResult IdentifierTable::add(U value)
     {
-        std::pair<HashSet<StringImpl*>::iterator, bool> result = m_table.add<U, V>(value);
-        (*result.first)->setIsIdentifier(true);
+        HashSet<StringImpl*>::AddResult result = m_table.add<U, V>(value);
+        (*result.iterator)->setIsIdentifier(true);
         return result;
     }
 
index 2c620b4..0ffa076 100644 (file)
@@ -195,10 +195,10 @@ void JSArray::finalize(JSCell* cell)
     thisObject->deallocateSparseMap();
 }
 
-inline std::pair<SparseArrayValueMap::iterator, bool> SparseArrayValueMap::add(JSArray* array, unsigned i)
+inline SparseArrayValueMap::AddResult SparseArrayValueMap::add(JSArray* array, unsigned i)
 {
     SparseArrayEntry entry;
-    std::pair<iterator, bool> result = m_map.add(i, entry);
+    AddResult result = m_map.add(i, entry);
     size_t capacity = m_map.capacity();
     if (capacity != m_reportedCapacity) {
         Heap::heap(array)->reportExtraMemoryCost((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier<Unknown>)));
@@ -209,14 +209,14 @@ inline std::pair<SparseArrayValueMap::iterator, bool> SparseArrayValueMap::add(J
 
 inline void SparseArrayValueMap::put(ExecState* exec, JSArray* array, unsigned i, JSValue value, bool shouldThrow)
 {
-    std::pair<SparseArrayValueMap::iterator, bool> result = add(array, i);
-    SparseArrayEntry& entry = result.first->second;
+    AddResult result = add(array, i);
+    SparseArrayEntry& entry = result.iterator->second;
 
     // To save a separate find & add, we first always add to the sparse map.
     // In the uncommon case that this is a new property, and the array is not
     // extensible, this is not the right thing to have done - so remove again.
-    if (result.second && !array->isExtensible()) {
-        remove(result.first);
+    if (result.isNewEntry && !array->isExtensible()) {
+        remove(result.iterator);
         if (shouldThrow)
             throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
         return;
@@ -252,14 +252,14 @@ inline void SparseArrayValueMap::put(ExecState* exec, JSArray* array, unsigned i
 
 inline bool SparseArrayValueMap::putDirect(ExecState* exec, JSArray* array, unsigned i, JSValue value, bool shouldThrow)
 {
-    std::pair<SparseArrayValueMap::iterator, bool> result = add(array, i);
-    SparseArrayEntry& entry = result.first->second;
+    AddResult result = add(array, i);
+    SparseArrayEntry& entry = result.iterator->second;
 
     // To save a separate find & add, we first always add to the sparse map.
     // In the uncommon case that this is a new property, and the array is not
     // extensible, this is not the right thing to have done - so remove again.
-    if (result.second && !array->isExtensible()) {
-        remove(result.first);
+    if (result.isNewEntry && !array->isExtensible()) {
+        remove(result.iterator);
         return reject(exec, shouldThrow, "Attempting to define property on object that is not extensible.");
     }
 
@@ -355,7 +355,7 @@ void JSArray::enterDictionaryMode(JSGlobalData& globalData)
         // This will always be a new entry in the map, so no need to check we can write,
         // and attributes are default so no need to set them.
         if (value)
-            map->add(this, i).first->second.set(globalData, this, value);
+            map->add(this, i).iterator->second.set(globalData, this, value);
     }
 
     void* newRawStorage = 0;
@@ -430,15 +430,15 @@ bool JSArray::defineOwnNumericProperty(ExecState* exec, unsigned index, Property
     ASSERT(map);
 
     // 1. Let current be the result of calling the [[GetOwnProperty]] internal method of O with property name P.
-    std::pair<SparseArrayValueMap::iterator, bool> result = map->add(this, index);
-    SparseArrayEntry* entryInMap = &result.first->second;
+    SparseArrayValueMap::AddResult result = map->add(this, index);
+    SparseArrayEntry* entryInMap = &result.iterator->second;
 
     // 2. Let extensible be the value of the [[Extensible]] internal property of O.
     // 3. If current is undefined and extensible is false, then Reject.
     // 4. If current is undefined and extensible is true, then
-    if (result.second) {
+    if (result.isNewEntry) {
         if (!isExtensible()) {
-            map->remove(result.first);
+            map->remove(result.iterator);
             return reject(exec, throwException, "Attempting to define property on object that is not extensible.");
         }
 
index ad98d66..890fdf4 100644 (file)
@@ -55,6 +55,7 @@ namespace JSC {
     public:
         typedef Map::iterator iterator;
         typedef Map::const_iterator const_iterator;
+        typedef Map::AddResult AddResult;
 
         SparseArrayValueMap()
             : m_flags(Normal)
@@ -87,7 +88,7 @@ namespace JSC {
         // These methods may mutate the contents of the map
         void put(ExecState*, JSArray*, unsigned, JSValue, bool shouldThrow);
         bool putDirect(ExecState*, JSArray*, unsigned, JSValue, bool shouldThrow);
-        std::pair<iterator, bool> add(JSArray*, unsigned);
+        AddResult add(JSArray*, unsigned);
         iterator find(unsigned i) { return m_map.find(i); }
         // This should ASSERT the remove is valid (check the result of the find).
         void remove(iterator it) { m_map.remove(it); }
index 8efb406..9bae940 100644 (file)
@@ -45,7 +45,7 @@ void PropertyNameArray::add(StringImpl* identifier)
             for (size_t i = 0; i < size; ++i)
                 m_set.add(m_data->propertyNameVector()[i].impl());
         }
-        if (!m_set.add(identifier).second)
+        if (!m_set.add(identifier).isNewEntry)
             return;
     }
 
index e3408b0..127d028 100644 (file)
@@ -48,7 +48,7 @@ inline JSValue StringRecursionChecker::performCheck()
     int size = m_exec->globalData().stringRecursionCheckVisitedObjects.size();
     if (size >= MaxSmallThreadReentryDepth && size >= m_exec->globalData().maxReentryDepth)
         return throwStackOverflowError();
-    bool alreadyVisited = !m_exec->globalData().stringRecursionCheckVisitedObjects.add(m_thisObject).second;
+    bool alreadyVisited = !m_exec->globalData().stringRecursionCheckVisitedObjects.add(m_thisObject).isNewEntry;
     if (alreadyVisited)
         return emptyString(); // Return empty string to avoid infinite recursion.
     return JSValue(); // Indicate success.
index 6ee419d..52eb1c7 100644 (file)
@@ -102,12 +102,12 @@ inline void StructureTransitionTable::add(JSGlobalData& globalData, Structure* s
     // Newer versions of the STL have an std::make_pair function that takes rvalue references.
     // When either of the parameters are bitfields, the C++ compiler will try to bind them as lvalues, which is invalid. To work around this, use unary "+" to make the parameter an rvalue.
     // See https://bugs.webkit.org/show_bug.cgi?id=59261 for more details
-    std::pair<TransitionMap::iterator, bool> result = map()->add(globalData, make_pair(structure->m_nameInPrevious, +structure->m_attributesInPrevious), structure);
-    if (!result.second) {
+    TransitionMap::AddResult result = map()->add(globalData, make_pair(structure->m_nameInPrevious, +structure->m_attributesInPrevious), structure);
+    if (!result.isNewEntry) {
         // There already is an entry! - we should only hit this when despecifying.
-        ASSERT(result.first.get().second->m_specificValueInPrevious);
+        ASSERT(result.iterator.get().second->m_specificValueInPrevious);
         ASSERT(!structure->m_specificValueInPrevious);
-        map()->set(result.first, structure);
+        map()->set(result.iterator, structure);
     }
 }
 
index 1bb3cd5..f01a0c8 100644 (file)
@@ -79,6 +79,8 @@ public:
         map_iterator m_iterator;
     };
 
+    typedef WTF::HashTableAddResult<iterator> AddResult;
+
     WeakGCMap()
     {
     }
@@ -121,17 +123,18 @@ public:
         return m_map.get(key);
     }
 
-    pair<iterator, bool> add(JSGlobalData& globalData, const KeyType& key, ExternalType value)
+    AddResult add(JSGlobalData& globalData, const KeyType& key, ExternalType value)
     {
-        pair<typename MapType::iterator, bool> iter = m_map.add(key, 0);
-        if (iter.second) {
+        typename MapType::AddResult result = m_map.add(key, 0);
+        if (result.isNewEntry) {
             HandleSlot slot = globalData.heap.handleHeap()->allocate();
-            iter.first->second = slot;
+            result.iterator->second = slot;
             HandleHeap::heapFor(slot)->makeWeak(slot, this, FinalizerCallback::finalizerContextFor(key));
             HandleHeap::heapFor(slot)->writeBarrier(slot, value);
             *slot = value;
         }
-        return iter;
+        // WeakGCMap exposes a different iterator, so we need to wrap it and create our own AddResult.
+        return AddResult(iterator(result.iterator), result.isNewEntry);
     }
     
     void set(iterator iter, ExternalType value)
@@ -144,12 +147,12 @@ public:
 
     void set(JSGlobalData& globalData, const KeyType& key, ExternalType value)
     {
-        pair<typename MapType::iterator, bool> iter = m_map.add(key, 0);
-        HandleSlot slot = iter.first->second;
-        if (iter.second) {
+        typename MapType::AddResult result = m_map.add(key, 0);
+        HandleSlot slot = result.iterator->second;
+        if (result.isNewEntry) {
             slot = globalData.heap.handleHeap()->allocate();
             HandleHeap::heapFor(slot)->makeWeak(slot, this, key);
-            iter.first->second = slot;
+            result.iterator->second = slot;
         }
         HandleHeap::heapFor(slot)->writeBarrier(slot, value);
         *slot = value;
index 60d5992..9de39ad 100644 (file)
@@ -50,8 +50,8 @@ public:
             m_children = new Map();
     
         ProfileTreeNode newEntry;
-        pair<Map::iterator, bool> result = m_children->add(String(name), newEntry);
-        ProfileTreeNode* childInMap = &result.first->second;
+        Map::AddResult result = m_children->add(String(name), newEntry);
+        ProfileTreeNode* childInMap = &result.iterator->second;
         ++childInMap->m_count;
         return childInMap;
     }
index ef6f881..11e7f66 100644 (file)
@@ -1,3 +1,50 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Make HashTable<>::add() and derivate functions return an AddResult struct instead
+        of a pair. This struct contains contains 'iterator' and 'isNewEntry' members, that are
+        more readable at callsites than previous 'first' and 'second'.
+
+        * wtf/HashCountedSet.h:
+        (HashCountedSet):
+        (WTF::::add):
+        * wtf/HashMap.h:
+        (HashMap):
+        (WTF):
+        (WTF::::set):
+        * wtf/HashSet.h:
+        (HashSet):
+        (WTF::::add):
+        (WTF):
+        * wtf/HashTable.h:
+        (WTF::HashTableAddResult::HashTableAddResult):
+        (HashTableAddResult):
+        (WTF):
+        (HashTable):
+        (WTF::HashTable::add):
+        (WTF::::add):
+        (WTF::::addPassingHashCode):
+        * wtf/ListHashSet.h:
+        (ListHashSet):
+        (WTF::::add):
+        (WTF::::insertBefore):
+        * wtf/RefPtrHashMap.h:
+        (WTF):
+        (WTF::::set):
+        * wtf/Spectrum.h:
+        (WTF::Spectrum::add):
+        * wtf/WTFThreadData.cpp:
+        (JSC::IdentifierTable::add):
+        * wtf/WTFThreadData.h:
+        (IdentifierTable):
+        * wtf/text/AtomicString.cpp:
+        (WTF::addToStringTable):
+        (WTF::AtomicString::addSlowCase):
+
 2012-03-29  Andreas Kling  <kling@webkit.org>
 
         String: Subscript operator shouldn't force conversion to 16-bit characters.
index cafb264..d7d9e43 100644 (file)
@@ -36,6 +36,7 @@ namespace WTF {
         typedef Value ValueType;
         typedef typename ImplType::iterator iterator;
         typedef typename ImplType::const_iterator const_iterator;
+        typedef typename ImplType::AddResult AddResult;
         
         HashCountedSet() {}
         
@@ -57,7 +58,7 @@ namespace WTF {
         // Increases the count if an equal value is already present
         // the return value is a pair of an interator to the new value's 
         // location, and a bool that is true if an new entry was added.
-        std::pair<iterator, bool> add(const ValueType&);
+        AddResult add(const ValueType&);
         
         // Reduces the count of the value, and removes it if count
         // goes down to zero, returns true if the value is removed.
@@ -142,10 +143,10 @@ namespace WTF {
     }
     
     template<typename Value, typename HashFunctions, typename Traits>
-    inline std::pair<typename HashCountedSet<Value, HashFunctions, Traits>::iterator, bool> HashCountedSet<Value, HashFunctions, Traits>::add(const ValueType &value)
+    inline typename HashCountedSet<Value, HashFunctions, Traits>::AddResult HashCountedSet<Value, HashFunctions, Traits>::add(const ValueType &value)
     {
-        pair<iterator, bool> result = m_impl.add(value, 0); 
-        ++result.first->second;
+        AddResult result = m_impl.add(value, 0);
+        ++result.iterator->second;
         return result;
     }
     
index be7e9eb..26a9d9c 100644 (file)
@@ -66,6 +66,7 @@ namespace WTF {
     public:
         typedef HashTableIteratorAdapter<HashTableType, ValueType> iterator;
         typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator;
+        typedef typename HashTableType::AddResult AddResult;
 
     public:
         void swap(HashMap&);
@@ -94,12 +95,12 @@ namespace WTF {
         // replaces value but not key if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        pair<iterator, bool> set(const KeyType&, MappedPassInType); 
+        AddResult set(const KeyType&, MappedPassInType);
 
         // does nothing if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        pair<iterator, bool> add(const KeyType&, MappedPassInType); 
+        AddResult add(const KeyType&, MappedPassInType);
 
         void remove(const KeyType&);
         void remove(iterator);
@@ -122,12 +123,12 @@ namespace WTF {
         //   static unsigned hash(const T&);
         //   static bool equal(const ValueType&, const T&);
         //   static translate(ValueType&, const T&, unsigned hashCode);
-        template<typename T, typename HashTranslator> pair<iterator, bool> add(const T&, MappedPassInType);
+        template<typename T, typename HashTranslator> AddResult add(const T&, MappedPassInType);
 
         void checkConsistency() const;
 
     private:
-        pair<iterator, bool> inlineAdd(const KeyType&, MappedPassInReferenceType);
+        AddResult inlineAdd(const KeyType&, MappedPassInReferenceType);
 
         class HashMapKeysProxy : private HashMap {
         public:
@@ -319,34 +320,34 @@ namespace WTF {
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    inline pair<typename HashMap<T, U, V, W, X>::iterator, bool>
+    typename HashMap<T, U, V, W, X>::AddResult
     HashMap<T, U, V, W, X>::inlineAdd(const KeyType& key, MappedPassInReferenceType mapped) 
     {
         return m_impl.template add<HashMapTranslator<ValueTraits, HashFunctions> >(key, mapped);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<T, U, V, W, X>::iterator, bool>
+    typename HashMap<T, U, V, W, X>::AddResult
     HashMap<T, U, V, W, X>::set(const KeyType& key, MappedPassInType mapped) 
     {
-        pair<iterator, bool> result = inlineAdd(key, mapped);
-        if (!result.second) {
+        AddResult result = inlineAdd(key, mapped);
+        if (!result.isNewEntry) {
             // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            MappedTraits::store(mapped, result.first->second);
+            MappedTraits::store(mapped, result.iterator->second);
         }
         return result;
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
     template<typename TYPE, typename HashTranslator>
-    pair<typename HashMap<T, U, V, W, X>::iterator, bool>
+    typename HashMap<T, U, V, W, X>::AddResult
     HashMap<T, U, V, W, X>::add(const TYPE& key, MappedPassInType value)
     {
         return m_impl.template addPassingHashCode<HashMapTranslatorAdapter<ValueTraits, HashTranslator> >(key, value);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<T, U, V, W, X>::iterator, bool>
+    typename HashMap<T, U, V, W, X>::AddResult
     HashMap<T, U, V, W, X>::add(const KeyType& key, MappedPassInType mapped)
     {
         return inlineAdd(key, mapped);
index 33cb14d..1b3b2e2 100644 (file)
@@ -51,6 +51,7 @@ namespace WTF {
     public:
         typedef HashTableConstIteratorAdapter<HashTableType, ValueType> iterator;
         typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator;
+        typedef typename HashTableType::AddResult AddResult;
 
         void swap(HashSet&);
 
@@ -76,7 +77,7 @@ namespace WTF {
 
         // The return value is a pair of an interator to the new value's location, 
         // and a bool that is true if an new entry was added.
-        pair<iterator, bool> add(const ValueType&);
+        AddResult add(const ValueType&);
 
         // An alternate version of add() that finds the object by hashing and comparing
         // with some other type, to avoid the cost of type conversion if the object is already
@@ -86,7 +87,7 @@ namespace WTF {
         //   static translate(ValueType&, const T&, unsigned hashCode);
         // FIXME: We should reverse the order of the template arguments so that callers
         // can just pass the translator and let the compiler deduce T.
-        template<typename T, typename HashTranslator> pair<iterator, bool> add(const T&);
+        template<typename T, typename HashTranslator> AddResult add(const T&);
 
         void remove(const ValueType&);
         void remove(iterator);
@@ -177,14 +178,14 @@ namespace WTF {
     }
 
     template<typename T, typename U, typename V>
-    inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
+    inline typename HashSet<T, U, V>::AddResult HashSet<T, U, V>::add(const ValueType& value)
     {
         return m_impl.add(value);
     }
 
     template<typename Value, typename HashFunctions, typename Traits>
     template<typename T, typename HashTranslator>
-    inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
+    inline typename HashSet<Value, HashFunctions, Traits>::AddResult
     HashSet<Value, HashFunctions, Traits>::add(const T& value)
     {
         return m_impl.template addPassingHashCode<HashSetTranslatorAdapter<HashTranslator> >(value, value);
index 05722d9..9bd5482 100644 (file)
@@ -296,6 +296,12 @@ namespace WTF {
         template<typename T, typename U> static void translate(T& location, const U&, const T& value) { location = value; }
     };
 
+    template<typename IteratorType> struct HashTableAddResult {
+        HashTableAddResult(IteratorType iter, bool isNewEntry) : iterator(iter), isNewEntry(isNewEntry) { }
+        IteratorType iterator;
+        bool isNewEntry;
+    };
+
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     class HashTable {
     public:
@@ -305,6 +311,7 @@ namespace WTF {
         typedef Key KeyType;
         typedef Value ValueType;
         typedef IdentityHashTranslator<HashFunctions> IdentityTranslatorType;
+        typedef HashTableAddResult<iterator> AddResult;
 
         HashTable();
         ~HashTable() 
@@ -330,13 +337,13 @@ namespace WTF {
         int capacity() const { return m_tableSize; }
         bool isEmpty() const { return !m_keyCount; }
 
-        pair<iterator, bool> add(const ValueType& value) { return add<IdentityTranslatorType>(Extractor::extract(value), value); }
+        AddResult add(const ValueType& value) { return add<IdentityTranslatorType>(Extractor::extract(value), value); }
 
         // A special version of add() that finds the object by hashing and comparing
         // with some other type, to avoid the cost of type conversion if the object is already
         // in the table.
-        template<typename HashTranslator, typename T, typename Extra> pair<iterator, bool> add(const T& key, const Extra&);
-        template<typename HashTranslator, typename T, typename Extra> pair<iterator, bool> addPassingHashCode(const T& key, const Extra&);
+        template<typename HashTranslator, typename T, typename Extra> AddResult add(const T& key, const Extra&);
+        template<typename HashTranslator, typename T, typename Extra> AddResult addPassingHashCode(const T& key, const Extra&);
 
         iterator find(const KeyType& key) { return find<IdentityTranslatorType>(key); }
         const_iterator find(const KeyType& key) const { return find<IdentityTranslatorType>(key); }
@@ -665,7 +672,7 @@ namespace WTF {
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     template<typename HashTranslator, typename T, typename Extra>
-    inline pair<typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra& extra)
+    inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra& extra)
     {
         checkKey<HashTranslator>(key);
 
@@ -700,7 +707,7 @@ namespace WTF {
                     break;
                 
                 if (HashTranslator::equal(Extractor::extract(*entry), key))
-                    return std::make_pair(makeKnownGoodIterator(entry), false);
+                    return AddResult(makeKnownGoodIterator(entry), false);
                 
                 if (isDeletedBucket(*entry))
                     deletedEntry = entry;
@@ -711,7 +718,7 @@ namespace WTF {
                 if (isDeletedBucket(*entry))
                     deletedEntry = entry;
                 else if (HashTranslator::equal(Extractor::extract(*entry), key))
-                    return std::make_pair(makeKnownGoodIterator(entry), false);
+                    return AddResult(makeKnownGoodIterator(entry), false);
             }
 #if DUMP_HASHTABLE_STATS
             ++probeCount;
@@ -738,19 +745,19 @@ namespace WTF {
             // follow a pivot entry and return the new position.
             KeyType enteredKey = Extractor::extract(*entry);
             expand();
-            pair<iterator, bool> p = std::make_pair(find(enteredKey), true);
-            ASSERT(p.first != end());
-            return p;
+            AddResult result(find(enteredKey), true);
+            ASSERT(result.iterator != end());
+            return result;
         }
         
         internalCheckTableConsistency();
         
-        return std::make_pair(makeKnownGoodIterator(entry), true);
+        return AddResult(makeKnownGoodIterator(entry), true);
     }
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     template<typename HashTranslator, typename T, typename Extra>
-    inline pair<typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::addPassingHashCode(const T& key, const Extra& extra)
+    inline typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::AddResult HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::addPassingHashCode(const T& key, const Extra& extra)
     {
         checkKey<HashTranslator>(key);
 
@@ -768,7 +775,7 @@ namespace WTF {
         unsigned h = lookupResult.second;
         
         if (found)
-            return std::make_pair(makeKnownGoodIterator(entry), false);
+            return AddResult(makeKnownGoodIterator(entry), false);
         
         if (isDeletedBucket(*entry)) {
             initializeBucket(*entry);
@@ -783,14 +790,14 @@ namespace WTF {
             // follow a pivot entry and return the new position.
             KeyType enteredKey = Extractor::extract(*entry);
             expand();
-            pair<iterator, bool> p = std::make_pair(find(enteredKey), true);
-            ASSERT(p.first != end());
-            return p;
+            AddResult result(find(enteredKey), true);
+            ASSERT(result.iterator != end());
+            return result;
         }
 
         internalCheckTableConsistency();
 
-        return std::make_pair(makeKnownGoodIterator(entry), true);
+        return AddResult(makeKnownGoodIterator(entry), true);
     }
 
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
index 799466f..21e38d8 100644 (file)
@@ -81,6 +81,8 @@ namespace WTF {
         typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg> const_reverse_iterator;
         friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>;
 
+        typedef HashTableAddResult<iterator> AddResult;
+
         ListHashSet();
         ListHashSet(const ListHashSet&);
         ListHashSet& operator=(const ListHashSet&);
@@ -124,10 +126,10 @@ namespace WTF {
 
         // The return value of add is a pair of an iterator to the new value's location, 
         // and a bool that is true if an new entry was added.
-        pair<iterator, bool> add(const ValueType&);
+        AddResult add(const ValueType&);
 
-        pair<iterator, bool> insertBefore(const ValueType& beforeValue, const ValueType& newValue);
-        pair<iterator, bool> insertBefore(iterator it, const ValueType&);
+        AddResult insertBefore(const ValueType& beforeValue, const ValueType& newValue);
+        AddResult insertBefore(iterator, const ValueType&);
 
         void remove(const ValueType&);
         void remove(iterator);
@@ -695,26 +697,25 @@ namespace WTF {
     }
 
     template<typename T, size_t inlineCapacity, typename U>
-    pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::add(const ValueType &value)
+    typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::add(const ValueType &value)
     {
-        pair<typename ImplType::iterator, bool> result = m_impl.template add<BaseTranslator>(value, m_allocator.get());
-        if (result.second)
-            appendNode(*result.first);
-        return std::make_pair(makeIterator(*result.first), result.second);
+        typename ImplType::AddResult result = m_impl.template add<BaseTranslator>(value, m_allocator.get());
+        if (result.isNewEntry)
+            appendNode(*result.iterator);
+        return AddResult(makeIterator(*result.iterator), result.isNewEntry);
     }
 
     template<typename T, size_t inlineCapacity, typename U>
-    pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::insertBefore(iterator it, const ValueType& newValue)
+    typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::insertBefore(iterator it, const ValueType& newValue)
     {
-        pair<typename ImplType::iterator, bool> result = m_impl.template add<BaseTranslator>(newValue, m_allocator.get());
-        if (result.second)
-            insertNodeBefore(it.node(), *result.first);
-        return std::make_pair(makeIterator(*result.first), result.second);
-
+        typename ImplType::AddResult result = m_impl.template add<BaseTranslator>(newValue, m_allocator.get());
+        if (result.isNewEntry)
+            insertNodeBefore(it.node(), *result.iterator);
+        return AddResult(makeIterator(*result.iterator), result.isNewEntry);
     }
 
     template<typename T, size_t inlineCapacity, typename U>
-    pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue)
+    typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineCapacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue)
     {
         return insertBefore(find(beforeValue), newValue); 
     }
index f48a59c..0af36be 100644 (file)
@@ -60,6 +60,7 @@ namespace WTF {
     public:
         typedef HashTableIteratorAdapter<HashTableType, ValueType> iterator;
         typedef HashTableConstIteratorAdapter<HashTableType, ValueType> const_iterator;
+        typedef typename HashTableType::AddResult AddResult;
 
         void swap(HashMap&);
 
@@ -86,14 +87,14 @@ namespace WTF {
         // replaces value but not key if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        pair<iterator, bool> set(const KeyType&, MappedPassInType); 
-        pair<iterator, bool> set(RawKeyType, MappedPassInType); 
+        AddResult set(const KeyType&, MappedPassInType);
+        AddResult set(RawKeyType, MappedPassInType);
 
         // does nothing if key is already present
         // return value is a pair of the iterator to the key location, 
         // and a boolean that's true if a new value was actually added
-        pair<iterator, bool> add(const KeyType&, MappedPassInType); 
-        pair<iterator, bool> add(RawKeyType, MappedPassInType); 
+        AddResult add(const KeyType&, MappedPassInType);
+        AddResult add(RawKeyType, MappedPassInType);
 
         void remove(const KeyType&);
         void remove(RawKeyType);
@@ -104,8 +105,8 @@ namespace WTF {
         MappedPassOutType take(RawKeyType); // efficient combination of get with remove
 
     private:
-        pair<iterator, bool> inlineAdd(const KeyType&, MappedPassInReferenceType);
-        pair<iterator, bool> inlineAdd(RawKeyType, MappedPassInReferenceType);
+        AddResult inlineAdd(const KeyType&, MappedPassInReferenceType);
+        AddResult inlineAdd(RawKeyType, MappedPassInReferenceType);
 
         HashTableType m_impl;
     };
@@ -195,52 +196,52 @@ namespace WTF {
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    inline pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    inline typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::inlineAdd(const KeyType& key, MappedPassInReferenceType mapped) 
     {
         return m_impl.template add<Translator>(key, mapped);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    inline pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    inline typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::inlineAdd(RawKeyType key, MappedPassInReferenceType mapped) 
     {
         return m_impl.template add<Translator>(key, mapped);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::set(const KeyType& key, MappedPassInType mapped) 
     {
-        pair<iterator, bool> result = inlineAdd(key, mapped);
-        if (!result.second) {
+        AddResult result = inlineAdd(key, mapped);
+        if (!result.isNewEntry) {
             // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            MappedTraits::store(mapped, result.first->second);
+            MappedTraits::store(mapped, result.iterator->second);
         }
         return result;
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::set(RawKeyType key, MappedPassInType mapped) 
     {
-        pair<iterator, bool> result = inlineAdd(key, mapped);
-        if (!result.second) {
+        AddResult result = inlineAdd(key, mapped);
+        if (!result.isNewEntry) {
             // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            MappedTraits::store(mapped, result.first->second);
+            MappedTraits::store(mapped, result.iterator->second);
         }
         return result;
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::add(const KeyType& key, MappedPassInType mapped)
     {
         return inlineAdd(key, mapped);
     }
 
     template<typename T, typename U, typename V, typename W, typename X>
-    pair<typename HashMap<RefPtr<T>, U, V, W, X>::iterator, bool>
+    typename HashMap<RefPtr<T>, U, V, W, X>::AddResult
     HashMap<RefPtr<T>, U, V, W, X>::add(RawKeyType key, MappedPassInType mapped)
     {
         return inlineAdd(key, mapped);
index 59bc4a2..5e7a484 100644 (file)
@@ -42,9 +42,9 @@ public:
     
     void add(const T& key, unsigned long count = 1)
     {
-        std::pair<iterator, bool> result = m_map.add(key, count);
-        if (!result.second)
-            result.first->second += count;
+        typename HashMap<T, unsigned long>::AddResult result = m_map.add(key, count);
+        if (!result.isNewEntry)
+            result.iterator->second += count;
     }
     
     unsigned long get(const T& key) const
index ec5de72..3a903f8 100644 (file)
@@ -63,10 +63,10 @@ IdentifierTable::~IdentifierTable()
         (*iter)->setIsIdentifier(false);
 }
 
-std::pair<HashSet<StringImpl*>::iterator, bool> IdentifierTable::add(StringImpl* value)
+HashSet<StringImpl*>::AddResult IdentifierTable::add(StringImpl* value)
 {
-    std::pair<HashSet<StringImpl*>::iterator, bool> result = m_table.add(value);
-    (*result.first)->setIsIdentifier(true);
+    HashSet<StringImpl*>::AddResult result = m_table.add(value);
+    (*result.iterator)->setIsIdentifier(true);
     return result;
 }
 
index b02d10d..dbc5ba6 100644 (file)
@@ -46,9 +46,9 @@ class IdentifierTable {
 public:
     ~IdentifierTable();
 
-    std::pair<HashSet<StringImpl*>::iterator, bool> add(StringImpl* value);
+    HashSet<StringImpl*>::AddResult add(StringImpl* value);
     template<typename U, typename V>
-    std::pair<HashSet<StringImpl*>::iterator, bool> add(U value);
+    HashSet<StringImpl*>::AddResult add(U value);
 
     bool remove(StringImpl* r)
     {
index d775e7b..66bd785 100644 (file)
@@ -78,11 +78,11 @@ static inline HashSet<StringImpl*>& stringTable()
 template<typename T, typename HashTranslator>
 static inline PassRefPtr<StringImpl> addToStringTable(const T& value)
 {
-    pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable().add<T, HashTranslator>(value);
+    HashSet<StringImpl*>::AddResult addResult = stringTable().add<T, HashTranslator>(value);
 
     // If the string is newly-translated, then we need to adopt it.
     // The boolean in the pair tells us if that is so.
-    return addResult.second ? adoptRef(*addResult.first) : *addResult.first;
+    return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
 }
 
 struct CStringTranslator {
@@ -300,7 +300,7 @@ PassRefPtr<StringImpl> AtomicString::addSlowCase(StringImpl* r)
     if (!r->length())
         return StringImpl::empty();
 
-    StringImpl* result = *stringTable().add(r).first;
+    StringImpl* result = *stringTable().add(r).iterator;
     if (result == r)
         r->setIsAtomic(true);
     return result;
index 2536f2d..6dfe362 100644 (file)
@@ -1,3 +1,183 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair. No new tests, just a refactoring.
+
+        * Modules/webdatabase/SQLTransactionCoordinator.cpp:
+        (WebCore::SQLTransactionCoordinator::acquireLock):
+        * Modules/webdatabase/chromium/QuotaTracker.cpp:
+        (WebCore::QuotaTracker::updateDatabaseSize):
+        * bindings/js/DOMObjectHashTableMap.h:
+        (WebCore::DOMObjectHashTableMap::get):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::cacheDOMStructure):
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::cacheWrapper):
+        * bindings/js/JSDOMGlobalObject.h:
+        (WebCore::getDOMConstructor):
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::addListener):
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::setBreakpoint):
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneSerializer::startObjectInternal):
+        (WebCore::CloneSerializer::write):
+        * bindings/v8/NPV8Object.cpp:
+        (WebCore::npCreateV8ScriptObject):
+        * bridge/IdentifierRep.cpp:
+        (WebCore::IdentifierRep::get):
+        * bridge/NP_jsobject.cpp:
+        (ObjectMap::add):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::logUnimplementedPropertyID):
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::getFontData):
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        (WebCore::CSSFontSelector::getFontData):
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::CSSSegmentedFontFace::getFontData):
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::ApplyPropertyCounter::applyInheritValue):
+        (WebCore::ApplyPropertyCounter::applyValue):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::appendAuthorStylesheets):
+        (WebCore::CSSStyleSelector::collectMatchingRulesForList):
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::createIdentifierValue):
+        (WebCore::CSSValuePool::createColorValue):
+        (WebCore::CSSValuePool::createValue):
+        (WebCore::CSSValuePool::createFontFamilyValue):
+        (WebCore::CSSValuePool::createFontFaceValue):
+        * dom/CheckedRadioButtons.cpp:
+        (WebCore::RadioButtonGroup::add):
+        (WebCore::CheckedRadioButtons::addButton):
+        * dom/ChildListMutationScope.cpp:
+        (WebCore::ChildListMutationScope::MutationAccumulationRouter::incrementScopingLevel):
+        * dom/Document.cpp:
+        (WebCore::Document::windowNamedItems):
+        (WebCore::Document::documentNamedItems):
+        (WebCore::Document::getCSSCanvasElement):
+        (WebCore::Document::getItems):
+        * dom/DocumentEventQueue.cpp:
+        (WebCore::DocumentEventQueue::enqueueEvent):
+        (WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent):
+        (WebCore::DocumentEventQueue::pendingEventTimerFired):
+        * dom/DocumentOrderedMap.cpp:
+        (WebCore::DocumentOrderedMap::add):
+        * dom/EventListenerMap.cpp:
+        (WebCore::EventListenerMap::add):
+        * dom/Node.cpp:
+        (WebCore::Node::dumpStatistics):
+        (WebCore::Node::getElementsByTagName):
+        (WebCore::Node::getElementsByTagNameNS):
+        (WebCore::Node::getElementsByName):
+        (WebCore::Node::getElementsByClassName):
+        (WebCore::Node::collectMatchingObserversForMutation):
+        * dom/QualifiedName.cpp:
+        (WebCore::QualifiedName::init):
+        * dom/SpaceSplitString.cpp:
+        (WebCore::SpaceSplitStringData::create):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::updateAttributeStyle):
+        * html/HTMLCollection.cpp:
+        (WebCore::HTMLCollection::append):
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::diff):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::SelectorProfile::commitSelector):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::performSearch):
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::resolveBreakpoint):
+        * inspector/InspectorValues.h:
+        (WebCore::InspectorObject::setValue):
+        (WebCore::InspectorObject::setObject):
+        (WebCore::InspectorObject::setArray):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::addEntry):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::findOrCreateCacheGroup):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleTouchEvent):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::pageGroup):
+        (WebCore::PageGroup::addVisitedLink):
+        (WebCore::PageGroup::addUserScriptToWorld):
+        (WebCore::PageGroup::addUserStyleSheetToWorld):
+        * page/SecurityPolicy.cpp:
+        (WebCore::SecurityPolicy::addOriginAccessWhitelistEntry):
+        * page/TouchAdjustment.cpp:
+        (WebCore::TouchAdjustment::compileSubtargetList):
+        * platform/cf/BinaryPropertyList.cpp:
+        (WebCore::BinaryPropertyListPlan::writeInteger):
+        (WebCore::BinaryPropertyListPlan::writeString):
+        (WebCore::BinaryPropertyListPlan::writeIntegerArray):
+        * platform/graphics/blackberry/LayerTiler.cpp:
+        (WebCore::LayerTiler::addTileJob):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::findOrMakeClone):
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::revalidateTiles):
+        * platform/graphics/ca/win/LayerChangesFlusher.cpp:
+        (WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon):
+        * platform/graphics/chromium/FontUtilsChromiumWin.cpp:
+        (WebCore::getDerivedFontData):
+        * platform/graphics/chromium/cc/CCLayerAnimationController.cpp:
+        (WebCore::CCLayerAnimationController::startAnimationsWaitingForTargetAvailability):
+        * platform/graphics/mac/ComplexTextControllerATSUI.cpp:
+        (WebCore::initializeATSUStyle):
+        * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+        (WebCore::SimpleFontData::getCFStringAttributes):
+        * platform/graphics/mac/SimpleFontDataMac.mm:
+        (WebCore::SimpleFontData::canRenderCombiningCharacterSequence):
+        * platform/graphics/wince/FontPlatformData.cpp:
+        (WebCore::FixedSizeFontData::create):
+        * platform/gtk/RenderThemeGtk3.cpp:
+        (WebCore::getStyleContext):
+        * platform/mac/ThreadCheck.mm:
+        (WebCoreReportThreadViolation):
+        * platform/network/HTTPHeaderMap.cpp:
+        (WebCore::HTTPHeaderMap::add):
+        * platform/network/HTTPHeaderMap.h:
+        (HTTPHeaderMap):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::addHTTPHeaderField):
+        * plugins/PluginDatabase.cpp:
+        (WebCore::PluginDatabase::add):
+        (WebCore::PluginDatabase::loadPersistentMetadataCache):
+        * plugins/win/PluginDatabaseWin.cpp:
+        (WebCore::PluginDatabase::getPluginPathsInDirectories):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addPercentHeightDescendant):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::setLogicalWidthForTextRun):
+        * rendering/RenderNamedFlowThread.cpp:
+        (WebCore::RenderNamedFlowThread::addDependencyOnFlowThread):
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::setRenderBoxRegionInfo):
+        * rendering/svg/RenderSVGResourceGradient.cpp:
+        (WebCore::RenderSVGResourceGradient::applyResource):
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::applyResource):
+        * storage/StorageMap.cpp:
+        (WebCore::StorageMap::setItem):
+        (WebCore::StorageMap::importItem):
+        * svg/SVGDocumentExtensions.cpp:
+        (WebCore::SVGDocumentExtensions::addPendingResource):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::setRequestHeaderInternal):
+        * xml/XPathFunctions.cpp:
+        (WebCore::XPath::FunId::evaluate):
+        * xml/XPathPath.cpp:
+        (WebCore::XPath::LocationPath::evaluate):
+        * xml/XPathPredicate.cpp:
+        (WebCore::XPath::Union::evaluate):
+
 2012-03-29  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: improve window selection accuracy in vertical overview of timeline panel
index 4158c98..837b8fb 100644 (file)
@@ -75,7 +75,7 @@ void SQLTransactionCoordinator::acquireLock(SQLTransaction* transaction)
     CoordinationInfoMap::iterator coordinationInfoIterator = m_coordinationInfoMap.find(dbIdentifier);
     if (coordinationInfoIterator == m_coordinationInfoMap.end()) {
         // No pending transactions for this DB
-        coordinationInfoIterator = m_coordinationInfoMap.add(dbIdentifier, CoordinationInfo()).first;
+        coordinationInfoIterator = m_coordinationInfoMap.add(dbIdentifier, CoordinationInfo()).iterator;
     }
 
     CoordinationInfo& info = coordinationInfoIterator->second;
index 2a09627..10b08a2 100644 (file)
@@ -71,7 +71,7 @@ void QuotaTracker::updateDatabaseSize(
     unsigned long long databaseSize)
 {
     MutexLocker lockData(m_dataGuard);
-    HashMap<String, SizeMap>::iterator it = m_databaseSizes.add(originIdentifier, SizeMap()).first;
+    HashMap<String, SizeMap>::iterator it = m_databaseSizes.add(originIdentifier, SizeMap()).iterator;
     it->second.set(databaseName, databaseSize);
 }
 
index 2c0e948..216b945 100644 (file)
@@ -47,7 +47,7 @@ public:
         HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable);
         if (iter != m_map.end())
             return &iter->second;
-        return &m_map.set(staticTable, JSC::HashTable(*staticTable)).first->second;
+        return &m_map.set(staticTable, JSC::HashTable(*staticTable)).iterator->second;
     }
 
 private:
index 0050a73..c11f601 100644 (file)
@@ -258,7 +258,7 @@ Structure* cacheDOMStructure(JSDOMGlobalObject* globalObject, Structure* structu
 {
     JSDOMStructureMap& structures = globalObject->structures();
     ASSERT(!structures.contains(classInfo));
-    return structures.set(classInfo, WriteBarrier<Structure>(globalObject->globalData(), globalObject, structure)).first->second.get();
+    return structures.set(classInfo, WriteBarrier<Structure>(globalObject->globalData(), globalObject, structure)).iterator->second.get();
 }
 
 JSC::JSObject* toJSSequence(ExecState* exec, JSValue value, unsigned& length)
index b049d9b..7eebc77 100644 (file)
@@ -142,8 +142,8 @@ enum ParameterDefaultPolicy {
         if (setInlineCachedWrapper(world, domObject, wrapper))
             return;
         JSC::PassWeak<JSDOMWrapper> passWeak(*world->globalData(), wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject));
-        pair<DOMObjectWrapperMap::iterator, bool> result = world->m_wrappers.add(domObject, passWeak);
-        ASSERT_UNUSED(result, result.second);
+        DOMObjectWrapperMap::AddResult result = world->m_wrappers.add(domObject, passWeak);
+        ASSERT_UNUSED(result, result.isNewEntry);
     }
 
     template <typename DOMClass> inline void uncacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper)
index adcd388..74f35b0 100644 (file)
@@ -95,7 +95,7 @@ namespace WebCore {
         JSC::JSObject* constructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), const_cast<JSDOMGlobalObject*>(globalObject), globalObject->objectPrototype()), const_cast<JSDOMGlobalObject*>(globalObject));
         ASSERT(!const_cast<JSDOMGlobalObject*>(globalObject)->constructors().contains(&ConstructorClass::s_info));
         JSC::WriteBarrier<JSC::JSObject> temp;
-        const_cast<JSDOMGlobalObject*>(globalObject)->constructors().add(&ConstructorClass::s_info, temp).first->second.set(exec->globalData(), globalObject, constructor);
+        const_cast<JSDOMGlobalObject*>(globalObject)->constructors().add(&ConstructorClass::s_info, temp).iterator->second.set(exec->globalData(), globalObject, constructor);
         return constructor;
     }
 
index c8f16f5..bdee468 100755 (executable)
@@ -82,11 +82,11 @@ void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag
     ASSERT_ARG(listener, listener);
     ASSERT_ARG(page, page);
 
-    pair<PageListenersMap::iterator, bool> result = m_pageListenersMap.add(page, 0);
-    if (result.second)
-        result.first->second = new ListenerSet;
+    PageListenersMap::AddResult result = m_pageListenersMap.add(page, 0);
+    if (result.isNewEntry)
+        result.iterator->second = new ListenerSet;
 
-    ListenerSet* listeners = result.first->second;
+    ListenerSet* listeners = result.iterator->second;
     listeners->add(listener);
 
     recompileAllJSFunctionsSoon();
index f495ced..10ded70 100644 (file)
@@ -75,7 +75,7 @@ String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
         return "";
     SourceIdToBreakpointsMap::iterator it = m_sourceIdToBreakpoints.find(sourceIDValue);
     if (it == m_sourceIdToBreakpoints.end())
-        it = m_sourceIdToBreakpoints.set(sourceIDValue, LineToBreakpointMap()).first;
+        it = m_sourceIdToBreakpoints.set(sourceIDValue, LineToBreakpointMap()).iterator;
     if (it->second.contains(scriptBreakpoint.lineNumber + 1))
         return "";
     it->second.set(scriptBreakpoint.lineNumber + 1, scriptBreakpoint);
index 96f0a81..7ac155c 100644 (file)
@@ -392,13 +392,13 @@ private:
     bool startObjectInternal(JSObject* object)
     {
         // Record object for graph reconstruction
-        pair<ObjectPool::iterator, bool> iter = m_objectPool.add(object, m_objectPool.size());
+        ObjectPool::AddResult addResult = m_objectPool.add(object, m_objectPool.size());
         
         // Handle duplicate references
-        if (!iter.second) {
+        if (!addResult.isNewEntry) {
             write(ObjectReferenceTag);
-            ASSERT(static_cast<int32_t>(iter.first->second) < m_objectPool.size());
-            writeObjectIndex(iter.first->second);
+            ASSERT(static_cast<int32_t>(addResult.iterator->second) < m_objectPool.size());
+            writeObjectIndex(addResult.iterator->second);
             return false;
         }
         
@@ -726,10 +726,10 @@ private:
     void write(const Identifier& ident)
     {
         UString str = ident.ustring();
-        pair<StringConstantPool::iterator, bool> iter = m_constantPool.add(str.impl(), m_constantPool.size());
-        if (!iter.second) {
+        StringConstantPool::AddResult addResult = m_constantPool.add(str.impl(), m_constantPool.size());
+        if (!addResult.isNewEntry) {
             write(StringPoolTag);
-            writeStringIndex(iter.first->second);
+            writeStringIndex(addResult.iterator->second);
             return;
         }
 
index 6fdf373..5c33593 100644 (file)
@@ -163,7 +163,7 @@ NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWind
             }
         }
     } else {
-        iter = staticV8NPObjectMap()->set(v8ObjectHash, V8NPObjectVector()).first; 
+        iter = staticV8NPObjectMap()->set(v8ObjectHash, V8NPObjectVector()).iterator;
     }
 
     V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
index fed47ca..2acf141 100644 (file)
@@ -67,15 +67,15 @@ IdentifierRep* IdentifierRep::get(int intID)
         return identifier;
     }
     
-    pair<IntIdentifierMap::iterator, bool> result = intIdentifierMap().add(intID, 0); 
-    if (result.second) {
-        ASSERT(!result.first->second);
-        result.first->second = new IdentifierRep(intID);
+    IntIdentifierMap::AddResult result = intIdentifierMap().add(intID, 0);
+    if (result.isNewEntry) {
+        ASSERT(!result.iterator->second);
+        result.iterator->second = new IdentifierRep(intID);
         
-        identifierSet().add(result.first->second);
+        identifierSet().add(result.iterator->second);
     }
     
-    return result.first->second;
+    return result.iterator->second;
 }
 
 typedef HashMap<RefPtr<StringImpl>, IdentifierRep*> StringIdentifierMap;
@@ -93,15 +93,15 @@ IdentifierRep* IdentifierRep::get(const char* name)
         return 0;
   
     UString string = stringToUString(String::fromUTF8WithLatin1Fallback(name, strlen(name)));
-    pair<StringIdentifierMap::iterator, bool> result = stringIdentifierMap().add(string.impl(), 0);
-    if (result.second) {
-        ASSERT(!result.first->second);
-        result.first->second = new IdentifierRep(name);
+    StringIdentifierMap::AddResult result = stringIdentifierMap().add(string.impl(), 0);
+    if (result.isNewEntry) {
+        ASSERT(!result.iterator->second);
+        result.iterator->second = new IdentifierRep(name);
         
-        identifierSet().add(result.first->second);
+        identifierSet().add(result.iterator->second);
     }
     
-    return result.first->second;
+    return result.iterator->second;
 }
 
 bool IdentifierRep::isValid(IdentifierRep* identifier)
index 2cbe923..83986af 100644 (file)
@@ -63,7 +63,7 @@ public:
         HashMap<RootObject*, JSToNPObjectMap>::iterator iter = m_map.find(rootObject);
         if (iter == m_map.end()) {
             rootObject->addInvalidationCallback(&m_invalidationCallback);
-            iter = m_map.add(rootObject, JSToNPObjectMap()).first;
+            iter = m_map.add(rootObject, JSToNPObjectMap()).iterator;
         }
 
         ASSERT(iter->second.find(jsObject) == iter->second.end());
index b989c1d..5219097 100644 (file)
@@ -1247,7 +1247,7 @@ static PassRefPtr<CSSValue> counterToCSSValue(const RenderStyle* style, int prop
 static void logUnimplementedPropertyID(int propertyID)
 {
     DEFINE_STATIC_LOCAL(HashSet<int>, propertyIDSet, ());
-    if (!propertyIDSet.add(propertyID).second)
+    if (!propertyIDSet.add(propertyID).isNewEntry)
         return;
 
     LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(static_cast<CSSPropertyID>(propertyID)));
index e36735a..dd904d3 100644 (file)
@@ -114,7 +114,7 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri
     unsigned hashKey = (fontDescription.computedPixelSize() + 1) << 6 | fontDescription.widthVariant() << 4
                        | (fontDescription.textOrientation() == TextOrientationUpright ? 8 : 0) | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
 
-    SimpleFontData*& cachedData = m_fontDataTable.add(hashKey, 0).first->second;
+    SimpleFontData*& cachedData = m_fontDataTable.add(hashKey, 0).iterator->second;
     if (cachedData)
         return cachedData;
 
index 6d22fdc..e002f2f 100644 (file)
@@ -285,7 +285,7 @@ void CSSFontSelector::addFontFaceRule(const CSSFontFaceRule* fontFaceRule)
         if (familyName.isEmpty())
             continue;
 
-        OwnPtr<Vector<RefPtr<CSSFontFace> > >& familyFontFaces = m_fontFaces.add(familyName, nullptr).first->second;
+        OwnPtr<Vector<RefPtr<CSSFontFace> > >& familyFontFaces = m_fontFaces.add(familyName, nullptr).iterator->second;
         if (!familyFontFaces) {
             familyFontFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >);
 
@@ -487,13 +487,13 @@ FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, c
         return fontDataForGenericFamily(m_document, fontDescription, familyName);
     }
 
-    OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).first->second;
+    OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).iterator->second;
     if (!segmentedFontFaceCache)
         segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >);
 
     FontTraitsMask traitsMask = fontDescription.traitsMask();
 
-    RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).first->second;
+    RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).iterator->second;
     if (!face) {
         face = CSSSegmentedFontFace::create(this);
 
index e3d9b77..cf9ec9e 100644 (file)
@@ -106,7 +106,7 @@ FontData* CSSSegmentedFontFace::getFontData(const FontDescription& fontDescripti
     FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
     unsigned hashKey = ((fontDescription.computedPixelSize() + 1) << (FontTraitsMaskWidth + 1)) | ((fontDescription.orientation() == Vertical ? 1 : 0) << FontTraitsMaskWidth) | desiredTraitsMask;
 
-    SegmentedFontData*& fontData = m_fontDataTable.add(hashKey, 0).first->second;
+    SegmentedFontData*& fontData = m_fontDataTable.add(hashKey, 0).iterator->second;
     if (fontData)
         return fontData;
 
index 31a87af..041d6c8 100644 (file)
@@ -1004,7 +1004,7 @@ public:
         typedef CounterDirectiveMap::iterator Iterator;
         Iterator end = parentMap.end();
         for (Iterator it = parentMap.begin(); it != end; ++it) {
-            CounterDirectives& directives = map.add(it->first, CounterDirectives()).first->second;
+            CounterDirectives& directives = map.add(it->first, CounterDirectives()).iterator->second;
             if (counterBehavior == Reset) {
                 directives.m_reset = it->second.m_reset;
                 directives.m_resetValue = it->second.m_resetValue;
@@ -1052,7 +1052,7 @@ public:
 
             AtomicString identifier = static_cast<CSSPrimitiveValue*>(pair->first())->getStringValue();
             int value = static_cast<CSSPrimitiveValue*>(pair->second())->getIntValue();
-            CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).first->second;
+            CounterDirectives& directives = map.add(identifier.impl(), CounterDirectives()).iterator->second;
             if (counterBehavior == Reset) {
                 directives.m_reset = true;
                 directives.m_resetValue = value;
index ec2f972..e522a3c 100644 (file)
@@ -496,10 +496,10 @@ void CSSStyleSelector::appendAuthorStylesheets(unsigned firstNew, const Vector<R
 #if ENABLE(STYLE_SCOPED)
         const ContainerNode* scope = determineScope(cssSheet);
         if (scope) {
-            pair<ScopedRuleSetMap::iterator, bool> addResult = m_scopedAuthorStyles.add(scope, nullptr);
-            if (addResult.second)
-                addResult.first->second = adoptPtr(new RuleSet());
-            addResult.first->second->addRulesFromSheet(cssSheet, *m_medium, this, scope);
+            ScopedRuleSetMap::AddResult addResult = m_scopedAuthorStyles.add(scope, nullptr);
+            if (addResult.isNewEntry)
+                addResult.iterator->second = adoptPtr(new RuleSet());
+            addResult.iterator->second->addRulesFromSheet(cssSheet, *m_medium, this, scope);
             continue;
         }
 #endif
@@ -2380,7 +2380,7 @@ void RuleSet::addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map, const RuleDa
 {
     if (!key)
         return;
-    OwnPtr<Vector<RuleData> >& rules = map.add(key, nullptr).first->second;
+    OwnPtr<Vector<RuleData> >& rules = map.add(key, nullptr).iterator->second;
     if (!rules)
         rules = adoptPtr(new Vector<RuleData>);
     rules->append(ruleData);
index c46c704..05ba549 100644 (file)
@@ -55,10 +55,10 @@ PassRefPtr<CSSPrimitiveValue> CSSValuePool::createIdentifierValue(int ident)
         return CSSPrimitiveValue::createIdentifier(ident);
 
     RefPtr<CSSPrimitiveValue> dummyValue;
-    pair<IdentifierValueCache::iterator, bool> entry = m_identifierValueCache.add(ident, dummyValue);
-    if (entry.second)
-        entry.first->second = CSSPrimitiveValue::createIdentifier(ident);
-    return entry.first->second;
+    IdentifierValueCache::AddResult entry = m_identifierValueCache.add(ident, dummyValue);
+    if (entry.isNewEntry)
+        entry.iterator->second = CSSPrimitiveValue::createIdentifier(ident);
+    return entry.iterator->second;
 }
 
 PassRefPtr<CSSPrimitiveValue> CSSValuePool::createColorValue(unsigned rgbValue)
@@ -78,10 +78,10 @@ PassRefPtr<CSSPrimitiveValue> CSSValuePool::createColorValue(unsigned rgbValue)
         m_colorValueCache.clear();
 
     RefPtr<CSSPrimitiveValue> dummyValue;
-    pair<ColorValueCache::iterator, bool> entry = m_colorValueCache.add(rgbValue, dummyValue);
-    if (entry.second)
-        entry.first->second = CSSPrimitiveValue::createColor(rgbValue);
-    return entry.first->second;
+    ColorValueCache::AddResult entry = m_colorValueCache.add(rgbValue, dummyValue);
+    if (entry.isNewEntry)
+        entry.iterator->second = CSSPrimitiveValue::createColor(rgbValue);
+    return entry.iterator->second;
 }
 
 PassRefPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimitiveValue::UnitTypes type)
@@ -117,15 +117,15 @@ PassRefPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimiti
     }
 
     RefPtr<CSSPrimitiveValue> dummyValue;
-    pair<IntegerValueCache::iterator, bool> entry = cache->add(intValue, dummyValue);
-    if (entry.second)
-        entry.first->second = CSSPrimitiveValue::create(value, type);
-    return entry.first->second;
+    IntegerValueCache::AddResult entry = cache->add(intValue, dummyValue);
+    if (entry.isNewEntry)
+        entry.iterator->second = CSSPrimitiveValue::create(value, type);
+    return entry.iterator->second;
 }
 
 PassRefPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName)
 {
-    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(familyName, 0).first->second;
+    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(familyName, 0).iterator->second;
     if (!value)
         value = CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::CSS_STRING);
     return value;
@@ -138,7 +138,7 @@ PassRefPtr<CSSValueList> CSSValuePool::createFontFaceValue(const AtomicString& s
     if (m_fontFaceValueCache.size() > maximumFontFaceCacheSize)
         m_fontFaceValueCache.clear();
 
-    RefPtr<CSSValueList>& value = m_fontFaceValueCache.add(string, 0).first->second;
+    RefPtr<CSSValueList>& value = m_fontFaceValueCache.add(string, 0).iterator->second;
     if (!value)
         value = CSSParser::parseFontFaceValue(string, contextStyleSheet);
     return value;
index 470da2a..e672329 100644 (file)
@@ -77,7 +77,7 @@ void RadioButtonGroup::setCheckedButton(HTMLInputElement* button)
 void RadioButtonGroup::add(HTMLInputElement* button)
 {
     ASSERT(button->isRadioButton());
-    if (!m_members.add(button).second)
+    if (!m_members.add(button).isNewEntry)
         return;
     bool groupWasValid = isValid();
     if (button->required())
@@ -185,7 +185,7 @@ void CheckedRadioButtons::addButton(HTMLInputElement* element)
     if (!m_nameToGroupMap)
         m_nameToGroupMap = adoptPtr(new NameToGroupMap);
 
-    OwnPtr<RadioButtonGroup>& group = m_nameToGroupMap->add(element->name().impl(), PassOwnPtr<RadioButtonGroup>()).first->second;
+    OwnPtr<RadioButtonGroup>& group = m_nameToGroupMap->add(element->name().impl(), PassOwnPtr<RadioButtonGroup>()).iterator->second;
     if (!group)
         group = RadioButtonGroup::create();
     group->add(element);
index cbaaa4e..c5cb3ad 100644 (file)
@@ -211,9 +211,9 @@ void ChildListMutationScope::MutationAccumulationRouter::willRemoveChild(Node* t
 
 void ChildListMutationScope::MutationAccumulationRouter::incrementScopingLevel(Node* target)
 {
-    pair<ScopingLevelMap::iterator, bool> result = m_scopingLevels.add(target, 1);
-    if (!result.second) {
-        ++(result.first->second);
+    ScopingLevelMap::AddResult result = m_scopingLevels.add(target, 1);
+    if (!result.isNewEntry) {
+        ++(result.iterator->second);
         return;
     }
 
index c7e2bc4..867a8d6 100644 (file)
@@ -4519,7 +4519,7 @@ HTMLAllCollection* Document::all()
 
 HTMLCollection* Document::windowNamedItems(const AtomicString& name)
 {
-    OwnPtr<HTMLNameCollection>& collection = m_windowNamedItemCollections.add(name.impl(), nullptr).first->second;
+    OwnPtr<HTMLNameCollection>& collection = m_windowNamedItemCollections.add(name.impl(), nullptr).iterator->second;
     if (!collection)
         collection = HTMLNameCollection::create(this, WindowNamedItems, name);
     return collection.get();
@@ -4527,7 +4527,7 @@ HTMLCollection* Document::windowNamedItems(const AtomicString& name)
 
 HTMLCollection* Document::documentNamedItems(const AtomicString& name)
 {
-    OwnPtr<HTMLNameCollection>& collection = m_documentNamedItemCollections.add(name.impl(), nullptr).first->second;
+    OwnPtr<HTMLNameCollection>& collection = m_documentNamedItemCollections.add(name.impl(), nullptr).iterator->second;
     if (!collection)
         collection = HTMLNameCollection::create(this, DocumentNamedItems, name);
     return collection.get();
@@ -4920,7 +4920,7 @@ CanvasRenderingContext* Document::getCSSCanvasContext(const String& type, const
 
 HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
 {
-    RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).first->second;
+    RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).iterator->second;
     if (!element)
         element = HTMLCanvasElement::create(this);
     return element.get();
@@ -5723,12 +5723,12 @@ PassRefPtr<NodeList> Document::getItems(const String& typeNames)
     // In this case we need to create an unique string identifier to map such request in the cache.
     String localTypeNames = typeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : typeNames;
 
-    pair<NodeListsNodeData::MicroDataItemListCache::iterator, bool> result = nodeLists->m_microDataItemListCache.add(localTypeNames, 0);
-    if (!result.second)
-        return PassRefPtr<NodeList>(result.first->second);
+    NodeListsNodeData::MicroDataItemListCache::AddResult result = nodeLists->m_microDataItemListCache.add(localTypeNames, 0);
+    if (!result.isNewEntry)
+        return PassRefPtr<NodeList>(result.iterator->second);
 
     RefPtr<MicroDataItemList> list = MicroDataItemList::create(this, typeNames);
-    result.first->second = list.get();
+    result.iterator->second = list.get();
     return list.release();
 }
 
index 5b899b3..5494082 100644 (file)
@@ -77,7 +77,7 @@ bool DocumentEventQueue::enqueueEvent(PassRefPtr<Event> event)
         return false;
 
     ASSERT(event->target());
-    bool wasAdded = m_queuedEvents.add(event).second;
+    bool wasAdded = m_queuedEvents.add(event).isNewEntry;
     ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
     
     if (!m_pendingEventTimer->isActive())
@@ -100,7 +100,7 @@ void DocumentEventQueue::enqueueOrDispatchScrollEvent(PassRefPtr<Node> target, S
         return;
     }
 
-    if (!m_nodesWithQueuedScrollEvents.add(target.get()).second)
+    if (!m_nodesWithQueuedScrollEvents.add(target.get()).isNewEntry)
         return;
 
     scrollEvent->setTarget(target);
@@ -132,7 +132,7 @@ void DocumentEventQueue::pendingEventTimerFired()
 
     // Insert a marker for where we should stop.
     ASSERT(!m_queuedEvents.contains(0));
-    bool wasAdded = m_queuedEvents.add(0).second;
+    bool wasAdded = m_queuedEvents.add(0).isNewEntry;
     ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
 
     RefPtr<DocumentEventQueue> protector(this);
index bcb23b4..082aa07 100644 (file)
@@ -69,14 +69,14 @@ void DocumentOrderedMap::add(AtomicStringImpl* key, Element* element)
     if (!m_duplicateCounts.contains(key)) {
         // Fast path. The key is not already in m_duplicateCounts, so we assume that it's
         // also not already in m_map and try to add it. If that add succeeds, we're done.
-        pair<Map::iterator, bool> addResult = m_map.add(key, element);
-        if (addResult.second)
+        Map::AddResult addResult = m_map.add(key, element);
+        if (addResult.isNewEntry)
             return;
 
         // The add failed, so this key was already cached in m_map.
         // There are multiple elements with this key. Remove the m_map
         // cache for this key so get searches for it next time it is called.
-        m_map.remove(addResult.first);
+        m_map.remove(addResult.iterator);
         m_duplicateCounts.add(key);
     } else {
         // There are multiple elements with this key. Remove the m_map
index 774e665..c1fd4d7 100644 (file)
@@ -134,11 +134,11 @@ bool EventListenerMap::add(const AtomicString& eventType, PassRefPtr<EventListen
     }
 
     if (m_hashMap) {
-        pair<EventListenerHashMap::iterator, bool> result = m_hashMap->add(eventType, nullptr);
-        if (result.second)
-            result.first->second = adoptPtr(new EventListenerVector);
+        EventListenerHashMap::AddResult result = m_hashMap->add(eventType, nullptr);
+        if (result.isNewEntry)
+            result.iterator->second = adoptPtr(new EventListenerVector);
 
-        return addListenerToVector(result.first->second.get(), listener, useCapture);
+        return addListenerToVector(result.iterator->second.get(), listener, useCapture);
     }
 
     if (!m_singleEventListenerVector) {
index a5b2964..0407527 100644 (file)
@@ -185,9 +185,9 @@ void Node::dumpStatistics()
 
                 // Tag stats
                 Element* element = static_cast<Element*>(node);
-                pair<HashMap<String, size_t>::iterator, bool> result = perTagCount.add(element->tagName(), 1);
-                if (!result.second)
-                    result.first->second++;
+                HashMap<String, size_t>::AddResult result = perTagCount.add(element->tagName(), 1);
+                if (!result.isNewEntry)
+                    result.iterator->second++;
 
                 if (ElementAttributeData* attributeData = element->attributeData()) {
                     attributes += attributeData->length();
@@ -1612,12 +1612,12 @@ PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName)
 
     AtomicString localNameAtom = name;
 
-    pair<NodeListsNodeData::TagNodeListCache::iterator, bool> result = ensureRareData()->ensureNodeLists(this)->m_tagNodeListCache.add(localNameAtom, 0);
-    if (!result.second)
-        return PassRefPtr<TagNodeList>(result.first->second);
+    NodeListsNodeData::TagNodeListCache::AddResult result = ensureRareData()->ensureNodeLists(this)->m_tagNodeListCache.add(localNameAtom, 0);
+    if (!result.isNewEntry)
+        return PassRefPtr<TagNodeList>(result.iterator->second);
 
     RefPtr<TagNodeList> list = TagNodeList::create(this, starAtom, localNameAtom);
-    result.first->second = list.get();
+    result.iterator->second = list.get();
     return list.release();   
 }
 
@@ -1635,36 +1635,36 @@ PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceU
 
     AtomicString localNameAtom = name;
 
-    pair<NodeListsNodeData::TagNodeListCacheNS::iterator, bool> result
+    NodeListsNodeData::TagNodeListCacheNS::AddResult result
         = ensureRareData()->ensureNodeLists(this)->m_tagNodeListCacheNS.add(QualifiedName(nullAtom, localNameAtom, namespaceURI).impl(), 0);
-    if (!result.second)
-        return PassRefPtr<TagNodeList>(result.first->second);
+    if (!result.isNewEntry)
+        return PassRefPtr<TagNodeList>(result.iterator->second);
 
     RefPtr<TagNodeList> list = TagNodeList::create(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localNameAtom);
-    result.first->second = list.get();
+    result.iterator->second = list.get();
     return list.release();
 }
 
 PassRefPtr<NodeList> Node::getElementsByName(const String& elementName)
 {
-    pair<NodeListsNodeData::NameNodeListCache::iterator, bool> result = ensureRareData()->ensureNodeLists(this)->m_nameNodeListCache.add(elementName, 0);
-    if (!result.second)
-        return PassRefPtr<NodeList>(result.first->second);
+    NodeListsNodeData::NameNodeListCache::AddResult result = ensureRareData()->ensureNodeLists(this)->m_nameNodeListCache.add(elementName, 0);
+    if (!result.isNewEntry)
+        return PassRefPtr<NodeList>(result.iterator->second);
 
     RefPtr<NameNodeList> list = NameNodeList::create(this, elementName);
-    result.first->second = list.get();
+    result.iterator->second = list.get();
     return list.release();
 }
 
 PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames)
 {
-    pair<NodeListsNodeData::ClassNodeListCache::iterator, bool> result
+    NodeListsNodeData::ClassNodeListCache::AddResult result
         = ensureRareData()->ensureNodeLists(this)->m_classNodeListCache.add(classNames, 0);
-    if (!result.second)
-        return PassRefPtr<NodeList>(result.first->second);
+    if (!result.isNewEntry)
+        return PassRefPtr<NodeList>(result.iterator->second);
 
     RefPtr<ClassNodeList> list = ClassNodeList::create(this, classNames);
-    result.first->second = list.get();
+    result.iterator->second = list.get();
     return list.release();
 }
 
@@ -2591,9 +2591,9 @@ void Node::collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*,
             MutationObserverRegistration* registration = registry->at(i).get();
             if (registration->shouldReceiveMutationFrom(this, type, attributeName)) {
                 MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions();
-                pair<HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::iterator, bool> result = observers.add(registration->observer(), deliveryOptions);
-                if (!result.second)
-                    result.first->second |= deliveryOptions;
+                HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration->observer(), deliveryOptions);
+                if (!result.isNewEntry)
+                    result.iterator->second |= deliveryOptions;
 
             }
         }
@@ -2604,9 +2604,9 @@ void Node::collectMatchingObserversForMutation(HashMap<WebKitMutationObserver*,
             MutationObserverRegistration* registration = *iter;
             if (registration->shouldReceiveMutationFrom(this, type, attributeName)) {
                 MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions();
-                pair<HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::iterator, bool> result = observers.add(registration->observer(), deliveryOptions);
-                if (!result.second)
-                    result.first->second |= deliveryOptions;
+                HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration->observer(), deliveryOptions);
+                if (!result.isNewEntry)
+                    result.iterator->second |= deliveryOptions;
             }
         }
     }
index a742629..e085507 100644 (file)
@@ -56,9 +56,9 @@ void QualifiedName::init(const AtomicString& p, const AtomicString& l, const Ato
     if (!gNameCache)
         gNameCache = new QNameSet;
     QualifiedNameComponents components = { p.impl(), l.impl(), n.isEmpty() ? nullAtom.impl() : n.impl() };
-    pair<QNameSet::iterator, bool> addResult = gNameCache->add<QualifiedNameComponents, QNameComponentsTranslator>(components);
-    m_impl = *addResult.first;    
-    if (!addResult.second)
+    QNameSet::AddResult addResult = gNameCache->add<QualifiedNameComponents, QNameComponentsTranslator>(components);
+    m_impl = *addResult.iterator;
+    if (!addResult.isNewEntry)
         m_impl->ref();
 }
 
index 035c4a2..9cce7d9 100644 (file)
@@ -150,7 +150,7 @@ SpaceSplitStringData::~SpaceSplitStringData()
 
 PassRefPtr<SpaceSplitStringData> SpaceSplitStringData::create(const AtomicString& string)
 {
-    SpaceSplitStringData*& data = sharedDataMap().add(string, 0).first->second;
+    SpaceSplitStringData*& data = sharedDataMap().add(string, 0).iterator->second;
     if (!data) {
         data = new SpaceSplitStringData(string);
         return adoptRef(data);
index 5761f50..228aa86 100644 (file)
@@ -236,7 +236,7 @@ void StyledElement::updateAttributeStyle()
 
     PresentationAttributeCache::iterator cacheIterator;
     if (cacheHash) {
-        cacheIterator = presentationAttributeCache().add(cacheHash, nullptr).first;
+        cacheIterator = presentationAttributeCache().add(cacheHash, nullptr).iterator;
         if (cacheIterator->second && cacheIterator->second->key != cacheKey)
             cacheHash = 0;
     } else
index d11fee1..c3a7153 100644 (file)
@@ -359,7 +359,7 @@ PassRefPtr<NodeList> HTMLCollection::tags(const String& name)
 
 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element)
 {
-    OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).first->second;
+    OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).iterator->second;
     if (!vector)
         vector = adoptPtr(new Vector<Element*>);
     vector->append(element);
index 25dca33..d7fcb9a 100644 (file)
@@ -233,12 +233,12 @@ DOMPatchSupport::diff(const Vector<OwnPtr<Digest> >& oldList, const Vector<OwnPt
     DiffTable oldTable;
 
     for (size_t i = 0; i < newList.size(); ++i) {
-        DiffTable::iterator it = newTable.add(newList[i]->m_sha1, Vector<size_t>()).first;
+        DiffTable::iterator it = newTable.add(newList[i]->m_sha1, Vector<size_t>()).iterator;
         it->second.append(i);
     }
 
     for (size_t i = 0; i < oldList.size(); ++i) {
-        DiffTable::iterator it = oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).first;
+        DiffTable::iterator it = oldTable.add(oldList[i]->m_sha1, Vector<size_t>()).iterator;
         it->second.append(i);
     }
 
index dca81ca..064b862 100644 (file)
@@ -181,12 +181,12 @@ inline void SelectorProfile::commitSelector(bool matched)
     double matchTimeMs = WTF::currentTimeMS() - m_currentMatchData.startTime;
     m_totalMatchingTimeMs += matchTimeMs;
 
-    pair<RuleMatchingStatsMap::iterator, bool> result = m_ruleMatchingStats.add(makeKey(), RuleMatchingStats(m_currentMatchData, matchTimeMs, 1, matched ? 1 : 0));
-    if (!result.second) {
-        result.first->second.totalTime += matchTimeMs;
-        result.first->second.hits += 1;
+    RuleMatchingStatsMap::AddResult result = m_ruleMatchingStats.add(makeKey(), RuleMatchingStats(m_currentMatchData, matchTimeMs, 1, matched ? 1 : 0));
+    if (!result.isNewEntry) {
+        result.iterator->second.totalTime += matchTimeMs;
+        result.iterator->second.hits += 1;
         if (matched)
-            result.first->second.matches += 1;
+            result.iterator->second.matches += 1;
     }
 }
 
index c294239..8b9ad92 100644 (file)
@@ -881,7 +881,7 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
     }
 
     *searchId = IdentifiersFactory::createIdentifier();
-    SearchResults::iterator resultsIt = m_searchResults.add(*searchId, Vector<RefPtr<Node> >()).first;
+    SearchResults::iterator resultsIt = m_searchResults.add(*searchId, Vector<RefPtr<Node> >()).iterator;
 
     for (ListHashSet<Node*>::iterator it = resultCollector.begin(); it != resultCollector.end(); ++it)
         resultsIt->second.append(*it);
index f2aab4b..924be38 100644 (file)
@@ -333,7 +333,7 @@ PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak
 
     BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId);
     if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end())
-        debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).first;
+        debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).iterator;
     debugServerBreakpointIdsIterator->second.append(debugServerBreakpointId);
 
     RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Location::create()
index b3f6171..c91ad82 100644 (file)
@@ -282,21 +282,21 @@ inline void InspectorObject::setString(const String& name, const String& value)
 inline void InspectorObject::setValue(const String& name, PassRefPtr<InspectorValue> value)
 {
     ASSERT(value);
-    if (m_data.set(name, value).second)
+    if (m_data.set(name, value).isNewEntry)
         m_order.append(name);
 }
 
 inline void InspectorObject::setObject(const String& name, PassRefPtr<InspectorObject> value)
 {
     ASSERT(value);
-    if (m_data.set(name, value).second)
+    if (m_data.set(name, value).isNewEntry)
         m_order.append(name);
 }
 
 inline void InspectorObject::setArray(const String& name, PassRefPtr<InspectorArray> value)
 {
     ASSERT(value);
-    if (m_data.set(name, value).second)
+    if (m_data.set(name, value).isNewEntry)
         m_order.append(name);
 }
 
index e6229c4..4e42938 100644 (file)
@@ -1062,10 +1062,10 @@ void ApplicationCacheGroup::addEntry(const String& url, unsigned type)
         return;
     }
     
-    pair<EntryMap::iterator, bool> result = m_pendingEntries.add(url, type);
+    EntryMap::AddResult result = m_pendingEntries.add(url, type);
     
-    if (!result.second)
-        result.first->second |= type;
+    if (!result.isNewEntry)
+        result.iterator->second |= type;
 }
 
 void ApplicationCacheGroup::associateDocumentLoaderWithCache(DocumentLoader* loader, ApplicationCache* cache)
index 16a7ccf..5d103b2 100644 (file)
@@ -134,11 +134,11 @@ ApplicationCacheGroup* ApplicationCacheStorage::findOrCreateCacheGroup(const KUR
 {
     ASSERT(!manifestURL.hasFragmentIdentifier());
 
-    std::pair<CacheGroupMap::iterator, bool> result = m_cachesInMemory.add(manifestURL, 0);
+    CacheGroupMap::AddResult result = m_cachesInMemory.add(manifestURL, 0);
     
-    if (!result.second) {
-        ASSERT(result.first->second);
-        return result.first->second;
+    if (!result.isNewEntry) {
+        ASSERT(result.iterator->second);
+        return result.iterator->second;
     }
 
     // Look up the group in the database
@@ -150,7 +150,7 @@ ApplicationCacheGroup* ApplicationCacheStorage::findOrCreateCacheGroup(const KUR
         m_cacheHostSet.add(urlHostHash(manifestURL));
     }
     
-    result.first->second = group;
+    result.iterator->second = group;
     
     return group;
 }
index a71e851..29364cd 100644 (file)
@@ -3516,7 +3516,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event)
         // Ensure this target's touch list exists, even if it ends up empty, so it can always be passed to TouchEvent::Create below.
         TargetTouchesMap::iterator targetTouchesIterator = touchesByTarget.find(touchTarget.get());
         if (targetTouchesIterator == touchesByTarget.end())
-            targetTouchesIterator = touchesByTarget.set(touchTarget.get(), TouchList::create()).first;
+            targetTouchesIterator = touchesByTarget.set(touchTarget.get(), TouchList::create()).iterator;
 
         // touches and targetTouches should only contain information about touches still on the screen, so if this point is
         // released or cancelled it will only appear in the changedTouches list.
index 731e1fc..f939c9b 100644 (file)
@@ -90,15 +90,15 @@ PageGroup* PageGroup::pageGroup(const String& groupName)
     if (!pageGroups)
         pageGroups = new PageGroupMap;
 
-    pair<PageGroupMap::iterator, bool> result = pageGroups->add(groupName, 0);
+    PageGroupMap::AddResult result = pageGroups->add(groupName, 0);
 
-    if (result.second) {
-        ASSERT(!result.first->second);
-        result.first->second = new PageGroup(groupName);
+    if (result.isNewEntry) {
+        ASSERT(!result.iterator->second);
+        result.iterator->second = new PageGroup(groupName);
     }
 
-    ASSERT(result.first->second);
-    return result.first->second;
+    ASSERT(result.iterator->second);
+    return result.iterator->second;
 }
 
 void PageGroup::closeLocalStorage()
@@ -197,7 +197,7 @@ inline void PageGroup::addVisitedLink(LinkHash hash)
 {
     ASSERT(shouldTrackVisitedLinks);
 #if !PLATFORM(CHROMIUM)
-    if (!m_visitedLinkHashes.add(hash).second)
+    if (!m_visitedLinkHashes.add(hash).isNewEntry)
         return;
 #endif
     Page::visitedStateChanged(this, hash);
@@ -269,7 +269,7 @@ void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& sourc
     OwnPtr<UserScript> userScript = adoptPtr(new UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames));
     if (!m_userScripts)
         m_userScripts = adoptPtr(new UserScriptMap);
-    OwnPtr<UserScriptVector>& scriptsInWorld = m_userScripts->add(world, nullptr).first->second;
+    OwnPtr<UserScriptVector>& scriptsInWorld = m_userScripts->add(world, nullptr).iterator->second;
     if (!scriptsInWorld)
         scriptsInWorld = adoptPtr(new UserScriptVector);
     scriptsInWorld->append(userScript.release());
@@ -286,7 +286,7 @@ void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& s
     OwnPtr<UserStyleSheet> userStyleSheet = adoptPtr(new UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level));
     if (!m_userStyleSheets)
         m_userStyleSheets = adoptPtr(new UserStyleSheetMap);
-    OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(world, nullptr).first->second;
+    OwnPtr<UserStyleSheetVector>& styleSheetsInWorld = m_userStyleSheets->add(world, nullptr).iterator->second;
     if (!styleSheetsInWorld)
         styleSheetsInWorld = adoptPtr(new UserStyleSheetVector);
     styleSheetsInWorld->append(userStyleSheet.release());
index 931f260..c2a5ab1 100644 (file)
@@ -131,11 +131,11 @@ void SecurityPolicy::addOriginAccessWhitelistEntry(const SecurityOrigin& sourceO
         return;
 
     String sourceString = sourceOrigin.toString();
-    pair<OriginAccessMap::iterator, bool> result = originAccessMap().add(sourceString, nullptr);
-    if (result.second)
-        result.first->second = adoptPtr(new OriginAccessWhiteList);
+    OriginAccessMap::AddResult result = originAccessMap().add(sourceString, nullptr);
+    if (result.isNewEntry)
+        result.iterator->second = adoptPtr(new OriginAccessWhiteList);
 
-    OriginAccessWhiteList* list = result.first->second.get();
+    OriginAccessWhiteList* list = result.iterator->second.get();
     list->append(OriginAccessEntry(destinationProtocol, destinationDomain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::DisallowSubdomains));
 }
 
index dd05461..da63afa 100644 (file)
@@ -132,8 +132,8 @@ void compileSubtargetList(const NodeList& intersectedNodes, SubtargetGeometryLis
                 respondingNode = visitedNode;
                 // Continue the iteration to collect the ancestors of the responder, which we will need later.
                 for (visitedNode = visitedNode->parentOrHostNode(); visitedNode; visitedNode = visitedNode->parentOrHostNode()) {
-                    pair<HashSet<Node*>::iterator, bool> addResult = ancestorsToRespondersSet.add(visitedNode);
-                    if (!addResult.second)
+                    HashSet<Node*>::AddResult addResult = ancestorsToRespondersSet.add(visitedNode);
+                    if (!addResult.isNewEntry)
                         break;
                 }
                 break;
index 4b823b1..4bc7c2e 100644 (file)
@@ -204,7 +204,7 @@ void BinaryPropertyListPlan::writeInteger(int integer)
             return;
         m_integerZeroObjectReference = m_currentObjectReference;
     } else {
-        if (!m_integers.add(integer, m_currentObjectReference).second)
+        if (!m_integers.add(integer, m_currentObjectReference).isNewEntry)
             return;
     }
     ++m_currentObjectReference;
@@ -214,7 +214,7 @@ void BinaryPropertyListPlan::writeInteger(int integer)
 void BinaryPropertyListPlan::writeString(const String& string)
 {
     ++m_currentAggregateSize;
-    if (!m_strings.add(string, m_currentObjectReference).second)
+    if (!m_strings.add(string, m_currentObjectReference).isNewEntry)
         return;
     ++m_currentObjectReference;
     writeStringObject(string);
@@ -224,12 +224,12 @@ void BinaryPropertyListPlan::writeIntegerArray(const int* integers, size_t size)
 {
     size_t savedAggregateSize = ++m_currentAggregateSize;
     ASSERT(size);
-    pair<IntegerArrayMap::iterator, bool> addResult = m_integerArrays.add(IntegerArray(integers, size), 0);
-    if (!addResult.second)
+    IntegerArrayMap::AddResult addResult = m_integerArrays.add(IntegerArray(integers, size), 0);
+    if (!addResult.isNewEntry)
         return;
     for (size_t i = 0; i < size; ++i)
         writeInteger(integers[i]);
-    addResult.first->second = m_currentObjectReference++;
+    addResult.iterator->second = m_currentObjectReference++;
     writeArrayObject(size);
     m_currentAggregateSize = savedAggregateSize;
 }
index 1b5a731..d517aaa 100644 (file)
@@ -428,18 +428,18 @@ void LayerTiler::processTextureJob(const TextureJob& job, TileJobsMap& tileJobsM
 void LayerTiler::addTileJob(const TileIndex& index, const TextureJob& job, TileJobsMap& tileJobsMap)
 {
     // HashMap::add always returns a valid iterator even the key already exists.
-    pair<TileJobsMap::iterator, bool> result = tileJobsMap.add(index, &job);
+    TileJobsMap::AddResult result = tileJobsMap.add(index, &job);
 
     // Successfully added the new job.
-    if (result.second)
+    if (result.isNewEntry)
         return;
 
     // In this case we leave the previous job.
-    if (job.m_type == TextureJob::DirtyContents && result.first->second->m_type == TextureJob::DiscardContents)
+    if (job.m_type == TextureJob::DirtyContents && result.iterator->second->m_type == TextureJob::DiscardContents)
         return;
 
     // Override the previous job.
-    result.first->second = &job;
+    result.iterator->second = &job;
 }
 
 void LayerTiler::performTileJob(LayerTile* tile, const TextureJob& job, const IntRect& tileRect)
index f6ccb95..1c01b69 100644 (file)
@@ -2488,16 +2488,16 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCA::findOrMakeClone(CloneID cloneID, Pl
     // Add with a dummy value to get an iterator for the insertion position, and a boolean that tells
     // us whether there's an item there. This technique avoids two hash lookups.
     RefPtr<PlatformCALayer> dummy;
-    pair<LayerMap::iterator, bool> addResult = clones->add(cloneID, dummy);
-    if (!addResult.second) {
+    LayerMap::AddResult addResult = clones->add(cloneID, dummy);
+    if (!addResult.isNewEntry) {
         // Value was not added, so it exists already.
-        resultLayer = addResult.first->second.get();
+        resultLayer = addResult.iterator->second.get();
     } else {
         resultLayer = cloneLayer(sourceLayer, cloneLevel);
 #ifndef NDEBUG
         resultLayer->setName(String::format("Clone %d of layer %p", cloneID[0U], sourceLayer->platformLayer()));
 #endif
-        addResult.first->second = resultLayer;
+        addResult.iterator->second = resultLayer;
     }
 
     return resultLayer;
index d932c1f..097dfbf 100644 (file)
@@ -364,7 +364,7 @@ void TileCache::revalidateTiles()
             TileIndex tileIndex(x, y);
 
             IntRect tileRect = rectForTileIndex(tileIndex);
-            RetainPtr<WebTileLayer>& tileLayer = m_tiles.add(tileIndex, 0).first->second;
+            RetainPtr<WebTileLayer>& tileLayer = m_tiles.add(tileIndex, 0).iterator->second;
             if (!tileLayer) {
                 tileLayer = createTileLayer(tileRect);
                 [m_tileContainerLayer.get() addSublayer:tileLayer.get()];
index 00c6308..b4feaee 100644 (file)
@@ -49,7 +49,7 @@ LayerChangesFlusher::LayerChangesFlusher()
 
 void LayerChangesFlusher::flushPendingLayerChangesSoon(AbstractCACFLayerTreeHost* host)
 {
-    if (!m_hostsWithChangesToFlush.add(host).second || m_hook)
+    if (!m_hostsWithChangesToFlush.add(host).isNewEntry || m_hook)
         return;
 
     setHook();
index 711b896..cc52c52 100644 (file)
@@ -414,8 +414,8 @@ bool getDerivedFontData(const UChar* family,
         // a font even if there's no font matching the name. Need to
         // check it against what we actually want (as is done in
         // FontCacheWin.cpp)
-        pair<FontDataCache::iterator, bool> entry = fontDataCache.add(fontKey, FontData());
-        derived = &entry.first->second;
+        FontDataCache::AddResult entry = fontDataCache.add(fontKey, FontData());
+        derived = &entry.iterator->second;
         derived->hfont = CreateFontIndirect(logfont);
         // GetAscent may return kUndefinedAscent, but we still want to
         // cache it so that we won't have to call CreateFontIndirect once
index 372a0e0..98ef254 100644 (file)
@@ -311,7 +311,7 @@ void CCLayerAnimationController::startAnimationsWaitingForTargetAvailability(dou
             // of blocked properties.
             bool nullIntersection = true;
             for (TargetProperties::iterator pIter = enqueuedProperties.begin(); pIter != enqueuedProperties.end(); ++pIter) {
-                if (!blockedProperties.add(*pIter).second)
+                if (!blockedProperties.add(*pIter).isNewEntry)
                     nullIntersection = false;
             }
 
index 0437bcd..be9f741 100644 (file)
@@ -278,15 +278,15 @@ static void disableLigatures(const SimpleFontData* fontData, ATSUStyle atsuStyle
 static ATSUStyle initializeATSUStyle(const SimpleFontData* fontData, TypesettingFeatures typesettingFeatures)
 {
     unsigned key = typesettingFeatures + 1;
-    pair<HashMap<unsigned, ATSUStyle>::iterator, bool> addResult = fontData->m_ATSUStyleMap.add(key, 0);
-    ATSUStyle& atsuStyle = addResult.first->second;
-    if (!addResult.second)
+    HashMap<unsigned, ATSUStyle>::AddResult addResult = fontData->m_ATSUStyleMap.add(key, 0);
+    ATSUStyle& atsuStyle = addResult.iterator->second;
+    if (!addResult.isNewEntry)
         return atsuStyle;
 
     ATSUFontID fontID = fontData->platformData().ctFont() ? CTFontGetPlatformFont(fontData->platformData().ctFont(), 0) : 0;
     if (!fontID) {
         LOG_ERROR("unable to get ATSUFontID for %p", fontData->platformData().font());
-        fontData->m_ATSUStyleMap.remove(addResult.first);
+        fontData->m_ATSUStyleMap.remove(addResult.isNewEntry);
         return 0;
     }
 
index 832bb9d..0519374 100644 (file)
@@ -42,9 +42,9 @@ namespace WebCore {
 CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures, FontOrientation orientation) const
 {
     unsigned key = typesettingFeatures + 1;
-    pair<HashMap<unsigned, RetainPtr<CFDictionaryRef> >::iterator, bool> addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
-    RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.first->second;
-    if (!addResult.second)
+    HashMap<unsigned, RetainPtr<CFDictionaryRef> >::AddResult addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
+    RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.iterator->second;
+    if (!addResult.isNewEntry)
         return attributesDictionary.get();
     
     bool treatLineAsVertical = orientation == Vertical;
index 8f4a919..74b2686 100644 (file)
@@ -440,9 +440,9 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
     if (!m_combiningCharacterSequenceSupport)
         m_combiningCharacterSequenceSupport = adoptPtr(new HashMap<String, bool>);
 
-    pair<WTF::HashMap<String, bool>::iterator, bool> addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
-    if (!addResult.second)
-        return addResult.first->second;
+    WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
+    if (!addResult.isNewEntry)
+        return addResult.iterator->second;
 
     RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(platformData().ctFont(), 0));
 
@@ -462,7 +462,7 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
             return false;
     }
 
-    addResult.first->second = true;
+    addResult.iterator->second = true;
     return true;
 }
 
index 692fd6d..19790ad 100644 (file)
@@ -285,11 +285,11 @@ PassRefPtr<FixedSizeFontData> FixedSizeFontData::create(const AtomicString& fami
 static PassRefPtr<FixedSizeFontData> createFixedSizeFontData(const AtomicString& family, unsigned weight, bool italic)
 {
     FixedSizeFontDataKey key(family, weight, italic);
-    pair<FixedSizeFontCache::iterator, bool> result = g_fixedSizeFontCache.add(key, RefPtr<FixedSizeFontData>());
-    if (result.second)
-        result.first->second = FixedSizeFontData::create(family, weight, italic);
+    FixedSizeFontCache::AddResult result = g_fixedSizeFontCache.add(key, RefPtr<FixedSizeFontData>());
+    if (result.isNewEntry)
+        result.iterator->second = FixedSizeFontData::create(family, weight, italic);
 
-    return result.first->second;
+    return result.iterator->second;
 }
 
 static LONG toGDIFontWeight(FontWeight fontWeight)
index a669bc8..720f0fd 100644 (file)
@@ -77,9 +77,9 @@ static StyleContextMap& styleContextMap()
 
 static GtkStyleContext* getStyleContext(GType widgetType)
 {
-    std::pair<StyleContextMap::iterator, bool> result = styleContextMap().add(widgetType, 0);
-    if (!result.second)
-        return result.first->second.get();
+    StyleContextMap::AddResult result = styleContextMap().add(widgetType, 0);
+    if (!result.isNewEntry)
+        return result.iterator->second.get();
 
     GtkWidgetPath* path = gtk_widget_path_new();
     gtk_widget_path_append_type(path, widgetType);
@@ -111,7 +111,7 @@ static GtkStyleContext* getStyleContext(GType widgetType)
     gtk_style_context_set_path(context.get(), path);
     gtk_widget_path_free(path);
 
-    result.first->second = context;
+    result.iterator->second = context;
     return context.get();
 }
 
index 4792191..89fef03 100644 (file)
@@ -103,7 +103,7 @@ void WebCoreReportThreadViolation(const char* function, WebCore::ThreadViolation
         case NoThreadCheck:
             break;
         case LogOnFirstThreadViolation:
-            if (loggedFunctions.add(function).second) {
+            if (loggedFunctions.add(function).isNewEntry) {
                 NSLog(@"WebKit Threading Violation - %s called from secondary thread", function);
                 NSLog(@"Additional threading violations for this function will not be logged.");
             }
index 44c5681..50091e1 100644 (file)
@@ -72,7 +72,7 @@ String HTTPHeaderMap::get(const AtomicString& name) const
     return HashMap<AtomicString, String, CaseFoldingHash>::get(name);
 }
 
-pair<HTTPHeaderMap::iterator, bool> HTTPHeaderMap::add(const AtomicString& name, const String& value)
+HTTPHeaderMap::AddResult HTTPHeaderMap::add(const AtomicString& name, const String& value)
 {
     return HashMap<AtomicString, String, CaseFoldingHash>::add(name, value);
 }
@@ -108,7 +108,7 @@ bool HTTPHeaderMap::contains(const char* name) const
     return find<const char*, CaseFoldingCStringTranslator>(name) != end();
 }
 
-pair<HTTPHeaderMap::iterator, bool> HTTPHeaderMap::add(const char* name, const String& value)
+HTTPHeaderMap::AddResult HTTPHeaderMap::add(const char* name, const String& value)
 {
     return HashMap<AtomicString, String, CaseFoldingHash>::add<const char*, CaseFoldingCStringTranslator>(name, value);
 }
index 02071e3..12bde06 100644 (file)
@@ -51,12 +51,12 @@ namespace WebCore {
         
         String get(const AtomicString& name) const;
 
-        pair<iterator, bool> add(const AtomicString& name, const String& value);
+        AddResult add(const AtomicString& name, const String& value);
 
         // Alternate accessors that are faster than converting the char* to AtomicString first.
         bool contains(const char*) const;
         String get(const char*) const;
-        pair<iterator, bool> add(const char* name, const String& value);
+        AddResult add(const char* name, const String& value);
         
     };
 
index 43a64e9..3509792 100644 (file)
@@ -371,9 +371,9 @@ void ResourceRequestBase::setPriority(ResourceLoadPriority priority)
 void ResourceRequestBase::addHTTPHeaderField(const AtomicString& name, const String& value) 
 {
     updateResourceRequest();
-    pair<HTTPHeaderMap::iterator, bool> result = m_httpHeaderFields.add(name, value); 
-    if (!result.second)
-        result.first->second += "," + value;
+    HTTPHeaderMap::AddResult result = m_httpHeaderFields.add(name, value);
+    if (!result.isNewEntry)
+        result.iterator->second += "," + value;
 
     if (url().protocolIsInHTTPFamily())
         m_platformRequestUpdated = false;
index 3e598ba..6e814ae 100644 (file)
@@ -323,7 +323,7 @@ bool PluginDatabase::add(PassRefPtr<PluginPackage> prpPackage)
 
     RefPtr<PluginPackage> package = prpPackage;
 
-    if (!m_plugins.add(package).second)
+    if (!m_plugins.add(package).isNewEntry)
         return false;
 
     m_pluginsByPath.add(package->path(), package);
@@ -574,7 +574,7 @@ void PluginDatabase::loadPersistentMetadataCache()
 
         RefPtr<PluginPackage> package = PluginPackage::createPackageFromCache(path, lastModified, name, desc, mimeDesc);
 
-        if (package && cachedPlugins.add(package).second) {
+        if (package && cachedPlugins.add(package).isNewEntry) {
             cachedPluginPathsWithTimes.add(package->path(), package->lastModified());
             cachedPluginsByPath.add(package->path(), package);
         }
index 27121c6..ffb421a 100644 (file)
@@ -142,7 +142,7 @@ void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
                 continue;
 
             String fullPath = *it + "\\" + filename;
-            if (!uniqueFilenames.add(fullPath).second)
+            if (!uniqueFilenames.add(fullPath).isNewEntry)
                 continue;
 
             paths.add(fullPath);
index 6570747..8362aae 100755 (executable)
@@ -3833,7 +3833,7 @@ void RenderBlock::addPercentHeightDescendant(RenderBox* descendant)
         descendantSet = new HashSet<RenderBox*>;
         gPercentHeightDescendantsMap->set(this, descendantSet);
     }
-    bool added = descendantSet->add(descendant).second;
+    bool added = descendantSet->add(descendant).isNewEntry;
     if (!added) {
         ASSERT(gPercentHeightContainerMap->get(descendant));
         ASSERT(gPercentHeightContainerMap->get(descendant)->contains(this));
index e5d59bb..9dd2181 100755 (executable)
@@ -662,14 +662,14 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
     run->m_box->setLogicalWidth(renderer->width(run->m_start, run->m_stop - run->m_start, xPos, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow) + hyphenWidth);
     if (!fallbackFonts.isEmpty()) {
         ASSERT(run->m_box->isText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         ASSERT(it->second.first.isEmpty());
         copyToVector(fallbackFonts, it->second.first);
         run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
     }
     if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
         ASSERT(run->m_box->isText());
-        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         it->second.second = glyphOverflow;
         run->m_box->clearKnownToHaveNoOverflow();
     }
index 8c1b6bf..dab5d7b 100644 (file)
@@ -217,8 +217,8 @@ void RenderNamedFlowThread::checkInvalidRegions()
 
 void RenderNamedFlowThread::addDependencyOnFlowThread(RenderNamedFlowThread* otherFlowThread)
 {
-    std::pair<RenderNamedFlowThreadCountedSet::iterator, bool> result = m_layoutBeforeThreadsSet.add(otherFlowThread);
-    if (result.second) {
+    RenderNamedFlowThreadCountedSet::AddResult result = m_layoutBeforeThreadsSet.add(otherFlowThread);
+    if (result.isNewEntry) {
         // This is the first time we see this dependency. Make sure we recalculate all the dependencies.
         view()->setIsRenderNamedFlowThreadOrderDirty(true);
     }
index cce25a7..de98ff8 100644 (file)
@@ -246,7 +246,7 @@ RenderBoxRegionInfo* RenderRegion::setRenderBoxRegionInfo(const RenderBox* box,
     if (!m_isValid || !m_flowThread)
         return 0;
 
-    OwnPtr<RenderBoxRegionInfo>& boxInfo = m_renderBoxRegionInfo.add(box, nullptr).first->second;
+    OwnPtr<RenderBoxRegionInfo>& boxInfo = m_renderBoxRegionInfo.add(box, nullptr).iterator->second;
     if (boxInfo)
         *boxInfo = RenderBoxRegionInfo(logicalLeftInset, logicalRightInset, containingBlockChainIsInset);
     else
index 907fe16..f8f493d 100644 (file)
@@ -140,7 +140,7 @@ bool RenderSVGResourceGradient::applyResource(RenderObject* object, RenderStyle*
     if (gradientUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && objectBoundingBox.isEmpty())
         return false;
 
-    OwnPtr<GradientData>& gradientData = m_gradientMap.add(object, nullptr).first->second;
+    OwnPtr<GradientData>& gradientData = m_gradientMap.add(object, nullptr).iterator->second;
     if (!gradientData)
         gradientData = adoptPtr(new GradientData);
 
index bec0f33..4dc501b 100644 (file)
@@ -83,7 +83,7 @@ bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
     if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX && objectBoundingBox.isEmpty())
         return false;
 
-    OwnPtr<PatternData>& patternData = m_patternMap.add(object, nullptr).first->second;
+    OwnPtr<PatternData>& patternData = m_patternMap.add(object, nullptr).iterator->second;
     if (!patternData)
         patternData = adoptPtr(new PatternData);
 
index 48db698..8e42d2f 100644 (file)
@@ -131,9 +131,9 @@ PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& valu
     }
     m_currentLength = newLength;
 
-    pair<HashMap<String, String>::iterator, bool> addResult = m_map.add(key, value);
-    if (!addResult.second)
-        addResult.first->second = value;
+    HashMap<String, String>::AddResult addResult = m_map.add(key, value);
+    if (!addResult.isNewEntry)
+        addResult.iterator->second = value;
 
     invalidateIterator();
 
@@ -171,8 +171,8 @@ void StorageMap::importItem(const String& key, const String& value)
 {
     // Be sure to copy the keys/values as items imported on a background thread are destined
     // to cross a thread boundary
-    pair<HashMap<String, String>::iterator, bool> result = m_map.add(key.isolatedCopy(), value.isolatedCopy());
-    ASSERT_UNUSED(result, result.second);  // True if the key didn't exist previously.
+    HashMap<String, String>::AddResult result = m_map.add(key.isolatedCopy(), value.isolatedCopy());
+    ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
 
     ASSERT(m_currentLength + key.length() >= m_currentLength);
     m_currentLength += key.length();
index 810b966..3f59705 100644 (file)
@@ -213,9 +213,9 @@ void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyled
 
     // The HashMap add function leaves the map alone and returns a pointer to the element in the
     // map if the element already exists. So we add with a value of 0, and it either finds the
-    // existing element or adds a new one in a single operation. The ".first->second" idiom gets
+    // existing element or adds a new one in a single operation. The ".iterator->second" idiom gets
     // us to the iterator from add's result, and then to the value inside the hash table.
-    SVGPendingElements*& set = m_pendingResources.add(id, 0).first->second;
+    SVGPendingElements*& set = m_pendingResources.add(id, 0).iterator->second;
     if (!set)
         set = new SVGPendingElements;
     set->add(element);
index 712200c..a71c445 100644 (file)
@@ -899,9 +899,9 @@ void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
 
 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const String& value)
 {
-    pair<HTTPHeaderMap::iterator, bool> result = m_requestHeaders.add(name, value);
-    if (!result.second)
-        result.first->second += ", " + value;
+    HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value);
+    if (!result.isNewEntry)
+        result.iterator->second += ", " + value;
 }
 
 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const
index 154b67e..707cc7f 100644 (file)
@@ -350,7 +350,7 @@ Value FunId::evaluate() const
         // If there are several nodes with the same id, id() should return the first one.
         // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
         Node* node = contextScope->getElementById(String(idList.characters() + startPos, endPos - startPos));
-        if (node && resultSet.add(node).second)
+        if (node && resultSet.add(node).isNewEntry)
             result.append(node);
         
         startPos = endPos;
index d9d1fd4..ba1ded3 100644 (file)
@@ -135,7 +135,7 @@ void LocationPath::evaluate(NodeSet& nodes) const
 
             for (size_t nodeIndex = 0; nodeIndex < matches.size(); ++nodeIndex) {
                 Node* node = matches[nodeIndex];
-                if (!needToCheckForDuplicateNodes || newNodesSet.add(node).second)
+                if (!needToCheckForDuplicateNodes || newNodesSet.add(node).isNewEntry)
                     newNodes.append(node);
             }
         }
index 58cd879..36800a1 100644 (file)
@@ -240,7 +240,7 @@ Value Union::evaluate() const
     
     for (size_t i = 0; i < rhsNodes.size(); ++i) {
         Node* node = rhsNodes[i];
-        if (nodes.add(node).second)
+        if (nodes.add(node).isNewEntry)
             resultSet.append(node);
     }
 
index 4aca5a4..4def755 100644 (file)
@@ -1,3 +1,17 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair.
+
+        * src/WebHTTPLoadInfo.cpp:
+        (WebKit::addHeader):
+        * src/WebURLResponse.cpp:
+        (WebKit::WebURLResponse::addHTTPHeaderField):
+
 2012-03-29  Mark Pilgrim  <pilgrim@chromium.org>
 
         GEOLOCATION should be implemented as Page Supplement
index e3dce8c..3c0cf15 100644 (file)
@@ -103,9 +103,9 @@ void WebHTTPLoadInfo::setEncodedDataLength(long long encodedDataLength)
 
 static void addHeader(HTTPHeaderMap* map, const WebString& name, const WebString& value)
 {
-    pair<HTTPHeaderMap::iterator, bool> result = map->add(name, value);
-    if (!result.second)
-        result.first->second += ", " + String(value);
+    HTTPHeaderMap::AddResult result = map->add(name, value);
+    if (!result.isNewEntry)
+        result.iterator->second += ", " + String(value);
 }
 
 void WebHTTPLoadInfo::addRequestHeader(const WebString& name, const WebString& value)
index ec212e5..07d5a45 100644 (file)
@@ -250,10 +250,10 @@ void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString&
     // FIXME: Add an addHTTPHeaderField method to ResourceResponse.
     const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
     String valueStr(value);
-    pair<HTTPHeaderMap::iterator, bool> result =
+    HTTPHeaderMap::AddResult result =
         const_cast<HTTPHeaderMap*>(&map)->add(name, valueStr);
-    if (!result.second)
-        result.first->second += ", " + valueStr;
+    if (!result.isNewEntry)
+        result.iterator->second += ", " + valueStr;
 }
 
 void WebURLResponse::clearHTTPHeaderField(const WebString& name)
index f788326..4a8958a 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair.
+
+        * Plugins/Hosted/NetscapePluginHostManager.mm:
+        (WebKit::NetscapePluginHostManager::hostForPlugin):
+        * Plugins/Hosted/ProxyInstance.mm:
+        (WebKit::ProxyInstance::methodsNamed):
+        (WebKit::ProxyInstance::fieldNamed):
+        * WebCoreSupport/WebNotificationClient.mm:
+        (WebNotificationClient::show):
+
 2012-03-29  Mark Pilgrim  <pilgrim@chromium.org>
 
         GEOLOCATION should be implemented as Page Supplement
index ce40f48..c510a9a 100644 (file)
@@ -69,15 +69,15 @@ NetscapePluginHostManager::~NetscapePluginHostManager()
 
 NetscapePluginHostProxy* NetscapePluginHostManager::hostForPlugin(const WTF::String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier)
 {
-    pair<PluginHostMap::iterator, bool> result = m_pluginHosts.add(pluginPath, 0);
+    PluginHostMap::AddResult result = m_pluginHosts.add(pluginPath, 0);
     
     // The package was already in the map, just return it.
-    if (!result.second)
-        return result.first->second;
+    if (!result.isNewEntry)
+        return result.iterator->second;
         
     mach_port_t clientPort;
     if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort) != KERN_SUCCESS) {
-        m_pluginHosts.remove(result.first);
+        m_pluginHosts.remove(result.iterator);
         return 0;
     }
     
@@ -85,7 +85,7 @@ NetscapePluginHostProxy* NetscapePluginHostManager::hostForPlugin(const WTF::Str
     ProcessSerialNumber pluginHostPSN;
     if (!spawnPluginHost(pluginPath, pluginArchitecture, clientPort, pluginHostPort, pluginHostPSN)) {
         mach_port_destroy(mach_task_self(), clientPort);
-        m_pluginHosts.remove(result.first);
+        m_pluginHosts.remove(result.iterator);
         return 0;
     }
     
@@ -95,7 +95,7 @@ NetscapePluginHostProxy* NetscapePluginHostManager::hostForPlugin(const WTF::Str
     
     NetscapePluginHostProxy* hostProxy = new NetscapePluginHostProxy(clientPort, pluginHostPort, pluginHostPSN, shouldCacheMissingPropertiesAndMethods);
     
-    result.first->second = hostProxy;
+    result.iterator->second = hostProxy;
     
     return hostProxy;
 }
index a39669c..09443dc 100644 (file)
@@ -376,13 +376,13 @@ MethodList ProxyInstance::methodsNamed(const Identifier& identifier)
         return MethodList();
 
     // Add a new entry to the map unless an entry was added while we were in waitForReply.
-    pair<MethodMap::iterator, bool> mapAddResult = m_methods.add(identifier.impl(), 0);
-    if (mapAddResult.second && reply->m_result)
-        mapAddResult.first->second = new ProxyMethod(methodName);
+    MethodMap::AddResult mapAddResult = m_methods.add(identifier.impl(), 0);
+    if (mapAddResult.isNewEntry && reply->m_result)
+        mapAddResult.iterator->second = new ProxyMethod(methodName);
 
     MethodList methodList;
-    if (mapAddResult.first->second)
-        methodList.append(mapAddResult.first->second);
+    if (mapAddResult.iterator->second)
+        methodList.append(mapAddResult.iterator->second);
     return methodList;
 }
 
@@ -412,10 +412,10 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier)
         return 0;
     
     // Add a new entry to the map unless an entry was added while we were in waitForReply.
-    pair<FieldMap::iterator, bool> mapAddResult = m_fields.add(identifier.impl(), 0);
-    if (mapAddResult.second && reply->m_result)
-        mapAddResult.first->second = new ProxyField(propertyName);
-    return mapAddResult.first->second;
+    FieldMap::AddResult mapAddResult = m_fields.add(identifier.impl(), 0);
+    if (mapAddResult.isNewEntry && reply->m_result)
+        mapAddResult.iterator->second = new ProxyField(propertyName);
+    return mapAddResult.iterator->second;
 }
 
 JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) const
index b0ffdfd..8120936 100644 (file)
@@ -71,7 +71,7 @@ bool WebNotificationClient::show(Notification* notification)
     RetainPtr<WebNotification> webNotification = adoptNS([[WebNotification alloc] initWithCoreNotification:notification notificationID:notificationID]);
     m_notificationMap.set(notification, webNotification);
 
-    NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<RetainPtr<WebNotification> >()).first;
+    NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<RetainPtr<WebNotification> >()).iterator;
     it->second.append(webNotification);
 
     [[m_webView _notificationProvider] showNotification:webNotification.get() fromWebView:m_webView];
index f2d7caf..f7ecc8c 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair.
+
+        * WebKitCOMAPI.cpp:
+        (classFactory):
+
 2012-03-29  Mark Pilgrim  <pilgrim@chromium.org>
 
         GEOLOCATION should be implemented as Page Supplement
index c4450f7..9c9cc02 100644 (file)
@@ -51,10 +51,9 @@ static COMPtr<IClassFactory> classFactory(const CLSID& clsid)
     typedef HashMap<CLSID, COMPtr<IClassFactory>, CLSIDHash, CLSIDHashTraits> FactoryMap;
     static FactoryMap& factories = *new FactoryMap;
 
-    pair<FactoryMap::iterator, bool> result = factories.add(clsid, 0);
-    COMPtr<IClassFactory>& factory = result.first->second;
-    bool added = result.second;
-    if (added && FAILED(DllGetClassObject(clsid, __uuidof(factory), reinterpret_cast<void**>(&factory))))
+    FactoryMap::AddResult result = factories.add(clsid, 0);
+    COMPtr<IClassFactory>& factory = result.iterator->second;
+    if (result.isNewEntry && FAILED(DllGetClassObject(clsid, __uuidof(factory), reinterpret_cast<void**>(&factory))))
         factory = 0;
 
     return factory;
index 29fccfd..09c1cd2 100644 (file)
@@ -1,3 +1,38 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair.
+
+        * Platform/CoreIPC/ArgumentCoders.h:
+        * Platform/CoreIPC/Connection.cpp:
+        (CoreIPC::Connection::SyncMessageState::getOrCreate):
+        * Shared/MutableDictionary.cpp:
+        (WebKit::MutableDictionary::add):
+        (WebKit::MutableDictionary::set):
+        * Shared/UserMessageCoders.h:
+        (WebKit::UserMessageDecoder::baseDecode):
+        * Shared/mac/CommandLineMac.cpp:
+        (WebKit::CommandLine::parse):
+        * UIProcess/API/mac/WKPrintingView.mm:
+        (pageDidDrawToPDF):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView validateUserInterfaceItem:]):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::addBackForwardItem):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::getOrCreate):
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::getOrCreate):
+        * WebProcess/Notifications/WebNotificationManager.cpp:
+        (WebKit::WebNotificationManager::show):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::createWebPage):
+        (WebKit::WebProcess::webPageGroup):
+
 2012-03-29  Mark Pilgrim  <pilgrim@chromium.org>
 
         GEOLOCATION should be implemented as Page Supplement
index a2ffa0f..070f458 100644 (file)
@@ -161,7 +161,7 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai
             if (!decoder->decode(value))
                 return false;
 
-            if (!tempHashMap.add(key, value).second) {
+            if (!tempHashMap.add(key, value).isNewEntry) {
                 // The hash map already has the specified key, bail.
                 decoder->markInvalid();
                 return false;
index 3c2f14c..f7c3723 100644 (file)
@@ -100,15 +100,15 @@ private:
 PassRefPtr<Connection::SyncMessageState> Connection::SyncMessageState::getOrCreate(RunLoop* runLoop)
 {
     MutexLocker locker(syncMessageStateMapMutex());
-    pair<SyncMessageStateMap::iterator, bool> result = syncMessageStateMap().add(runLoop, 0);
+    SyncMessageStateMap::AddResult result = syncMessageStateMap().add(runLoop, 0);
 
-    if (!result.second) {
-        ASSERT(result.first->second);
-        return result.first->second;
+    if (!result.isNewEntry) {
+        ASSERT(result.iterator->second);
+        return result.iterator->second;
     }
 
     RefPtr<SyncMessageState> syncMessageState = adoptRef(new SyncMessageState(runLoop));
-    result.first->second = syncMessageState.get();
+    result.iterator->second = syncMessageState.get();
 
     return syncMessageState.release();
 }
index 2f905ec..ac69b76 100644 (file)
@@ -38,14 +38,14 @@ MutableDictionary::~MutableDictionary()
 
 bool MutableDictionary::add(const String& key, APIObject* item)
 {
-    std::pair<MapType::iterator, bool> result = m_map.add(key, item);
-    return result.second;
+    MapType::AddResult result = m_map.add(key, item);
+    return result.isNewEntry;
 }
 
 bool MutableDictionary::set(const String& key, APIObject* item)
 {
-    std::pair<MapType::iterator, bool> result = m_map.set(key, item);
-    return result.second;
+    MapType::AddResult result = m_map.set(key, item);
+    return result.isNewEntry;
 }
 
 void MutableDictionary::remove(const String& key)
index 9672f28..ace72fd 100644 (file)
@@ -285,8 +285,8 @@ public:
                 if (!decoder->decode(messageCoder))
                     return false;
 
-                std::pair<ImmutableDictionary::MapType::iterator, bool> result = map.set(key, element.release());
-                if (!result.second)
+                ImmutableDictionary::MapType::AddResult result = map.set(key, element.release());
+                if (!result.isNewEntry)
                     return false;
             }
 
index d48a401..5001981 100644 (file)
@@ -48,7 +48,7 @@ bool CommandLine::parse(int argc, char** argv)
         if (value.isEmpty())
             return false;
         
-        if (!m_args.add(key, value).second)
+        if (!m_args.add(key, value).isNewEntry)
             return false;
     }
 
index 13aefb8..31258f2 100644 (file)
@@ -228,8 +228,8 @@ static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext
             ASSERT([view _isPrintingPreview]);
 
             if (data) {
-                pair<HashMap<WebCore::IntRect, Vector<uint8_t> >::iterator, bool> entry = view->_pagePreviews.add(iter->second, Vector<uint8_t>());
-                entry.first->second.append(data->bytes(), data->size());
+                HashMap<WebCore::IntRect, Vector<uint8_t> >::AddResult entry = view->_pagePreviews.add(iter->second, Vector<uint8_t>());
+                entry.iterator->second.append(data->bytes(), data->size());
             }
             view->_expectedPreviewCallbacks.remove(context->callbackID);
             bool receivedResponseToLatestRequest = view->_latestExpectedPreviewCallback == context->callbackID;
index 7f9579a..61e3b60 100644 (file)
@@ -721,9 +721,9 @@ static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int
         return YES;
 
     // Add this item to the vector of items for a given command that are awaiting validation.
-    pair<ValidationMap::iterator, bool> addResult = _data->_validationMap.add(commandName, ValidationVector());
-    addResult.first->second.append(item);
-    if (addResult.second) {
+    ValidationMap::AddResult addResult = _data->_validationMap.add(commandName, ValidationVector());
+    addResult.iterator->second.append(item);
+    if (addResult.isNewEntry) {
         // If we are not already awaiting validation for this command, start the asynchronous validation process.
         // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
         // we asked for the same command; there is no guarantee the answer is still valid.
index 9ce5440..e8dfd81 100644 (file)
@@ -271,18 +271,17 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& original
     MESSAGE_CHECK_URL(originalURL);
     MESSAGE_CHECK_URL(url);
 
-    std::pair<WebBackForwardListItemMap::iterator, bool> result = m_backForwardListItemMap.add(itemID, 0);
-    if (result.second) {
-        // New item.
-        result.first->second = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);
+    WebBackForwardListItemMap::AddResult result = m_backForwardListItemMap.add(itemID, 0);
+    if (result.isNewEntry) {
+        result.iterator->second = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);
         return;
     }
 
     // Update existing item.
-    result.first->second->setOriginalURL(originalURL);
-    result.first->second->setURL(url);
-    result.first->second->setTitle(title);
-    result.first->second->setBackForwardData(backForwardData.data(), backForwardData.size());
+    result.iterator->second->setOriginalURL(originalURL);
+    result.iterator->second->setURL(url);
+    result.iterator->second->setTitle(title);
+    result.iterator->second->setBackForwardData(backForwardData.data(), backForwardData.size());
 }
 
 #if ENABLE(PLUGIN_PROCESS)
index cebbb30..7d7305e 100644 (file)
@@ -67,12 +67,12 @@ PassRefPtr<InjectedBundleNodeHandle> InjectedBundleNodeHandle::getOrCreate(Node*
     if (!node)
         return 0;
 
-    std::pair<DOMHandleCache::iterator, bool> result = domHandleCache().add(node, 0);
-    if (!result.second)
-        return PassRefPtr<InjectedBundleNodeHandle>(result.first->second);
+    DOMHandleCache::AddResult result = domHandleCache().add(node, 0);
+    if (!result.isNewEntry)
+        return PassRefPtr<InjectedBundleNodeHandle>(result.iterator->second);
 
     RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::create(node);
-    result.first->second = nodeHandle.get();
+    result.iterator->second = nodeHandle.get();
     return nodeHandle.release();
 }
 
index e94edfd..1b74f01 100644 (file)
@@ -46,12 +46,12 @@ PassRefPtr<InjectedBundleRangeHandle> InjectedBundleRangeHandle::getOrCreate(Ran
     if (!range)
         return 0;
 
-    std::pair<DOMHandleCache::iterator, bool> result = domHandleCache().add(range, 0);
-    if (!result.second)
-        return PassRefPtr<InjectedBundleRangeHandle>(result.first->second);
+    DOMHandleCache::AddResult result = domHandleCache().add(range, 0);
+    if (!result.isNewEntry)
+        return PassRefPtr<InjectedBundleRangeHandle>(result.iterator->second);
 
     RefPtr<InjectedBundleRangeHandle> rangeHandle = InjectedBundleRangeHandle::create(range);
-    result.first->second = rangeHandle.get();
+    result.iterator->second = rangeHandle.get();
     return rangeHandle.release();
 }
 
index 27e4c72..26e5407 100644 (file)
@@ -115,7 +115,7 @@ bool WebNotificationManager::show(Notification* notification, WebPage* page)
     m_notificationMap.set(notification, notificationID);
     m_notificationIDMap.set(notificationID, notification);
     
-    NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).first;
+    NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator;
     it->second.append(notificationID);
     
     m_process->connection()->send(Messages::WebPageProxy::ShowNotification(notification->title(), notification->body(), notification->iconURL().string(), notification->replaceId(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->pageID());
index c1ba050..2dfcde0 100644 (file)
@@ -518,16 +518,16 @@ void WebProcess::createWebPage(uint64_t pageID, const WebPageCreationParameters&
 {
     // It is necessary to check for page existence here since during a window.open() (or targeted
     // link) the WebPage gets created both in the synchronous handler and through the normal way. 
-    std::pair<HashMap<uint64_t, RefPtr<WebPage> >::iterator, bool> result = m_pageMap.add(pageID, 0);
-    if (result.second) {
-        ASSERT(!result.first->second);
-        result.first->second = WebPage::create(pageID, parameters);
+    HashMap<uint64_t, RefPtr<WebPage> >::AddResult result = m_pageMap.add(pageID, 0);
+    if (result.isNewEntry) {
+        ASSERT(!result.iterator->second);
+        result.iterator->second = WebPage::create(pageID, parameters);
 
         // Balanced by an enableTermination in removeWebPage.
         disableTermination();
     }
 
-    ASSERT(result.first->second);
+    ASSERT(result.iterator->second);
 }
 
 void WebProcess::removeWebPage(uint64_t pageID)
@@ -739,13 +739,13 @@ WebPageGroupProxy* WebProcess::webPageGroup(uint64_t pageGroupID)
 
 WebPageGroupProxy* WebProcess::webPageGroup(const WebPageGroupData& pageGroupData)
 {
-    std::pair<HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::iterator, bool> result = m_pageGroupMap.add(pageGroupData.pageGroupID, 0);
-    if (result.second) {
-        ASSERT(!result.first->second);
-        result.first->second = WebPageGroupProxy::create(pageGroupData);
+    HashMap<uint64_t, RefPtr<WebPageGroupProxy> >::AddResult result = m_pageGroupMap.add(pageGroupData.pageGroupID, 0);
+    if (result.isNewEntry) {
+        ASSERT(!result.iterator->second);
+        result.iterator->second = WebPageGroupProxy::create(pageGroupData);
     }
 
-    return result.first->second.get();
+    return result.iterator->second.get();
 }
 
 static bool canPluginHandleResponse(const ResourceResponse& response)
index 73138a9..0dbe7c7 100644 (file)
@@ -1,3 +1,19 @@
+2012-03-29  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        HashMap<>::add should return a more descriptive object
+        https://bugs.webkit.org/show_bug.cgi?id=71063
+
+        Reviewed by Ryosuke Niwa.
+
+        Update code to use AddResult instead of a pair.
+
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::evaluateScriptInIsolatedWorld):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::evaluateScriptInIsolatedWorld):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::evaluateScriptInIsolatedWorld):
+
 2012-03-29  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Web Inspector: chromium: DRT --no-timeout option doesn't work.
index 90e5433..18991ce 100644 (file)
@@ -963,7 +963,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObj
     if (!worldID)
         world = [WebScriptWorld world];
     else {
-        RetainPtr<WebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
+        RetainPtr<WebScriptWorld>& worldSlot = worldMap().add(worldID, 0).iterator->second;
         if (!worldSlot)
             worldSlot.adoptNS([[WebScriptWorld alloc] init]);
         world = worldSlot.get();
index 80941b8..1b6a415 100644 (file)
@@ -1302,7 +1302,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObj
         if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
             return;
     } else {
-        COMPtr<IWebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
+        COMPtr<IWebScriptWorld>& worldSlot = worldMap().add(worldID, 0).iterator->second;
         if (!worldSlot && FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(worldSlot), reinterpret_cast<void**>(&worldSlot))))
             return;
         world = worldSlot;
index 0583486..cec4344 100644 (file)
@@ -504,7 +504,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(JSContextRef context, u
     if (!worldID)
         world.adopt(WKBundleScriptWorldCreateWorld());
     else {
-        WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).first->second;
+        WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).iterator->second;
         if (!worldSlot)
             worldSlot.adopt(WKBundleScriptWorldCreateWorld());
         world = worldSlot;