Changeset 154967 in webkit
- Timestamp:
- Sep 2, 2013 11:00:45 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r154966 r154967 1 2013-09-02 Darin Adler <darin@apple.com> 2 3 Cut down on double hashing and code needlessly using hash table iterators 4 https://bugs.webkit.org/show_bug.cgi?id=120611 5 6 Reviewed by Andreas Kling. 7 8 Double hashing is common in code that needs to combine a remove with some 9 action to only be done if the code is removed. The only way to avoid it is 10 to write code using find and a hash table iterator. To help with this, add 11 a boolean return value to remove functions to indicate if anything was removed. 12 13 Double hashing also happens in code that does a get followed by a remove. 14 The take function is helpful in this case. To help with this, add a takeFirst 15 funciton to ListHashSet. 16 17 * wtf/HashCountedSet.h: 18 (WTF::HashCountedSet::removeAll): Added a boolean return value, analogous to the one 19 that the HashCountedSet::remove function already has. 20 21 * wtf/HashMap.h: 22 (WTF::HashMap::remove): Added a boolean return value, true if something was removed. 23 * wtf/HashSet.h: 24 (WTF::HashSet::remove): Ditto. 25 * wtf/RefPtrHashMap.h: 26 (WTF::RefPtrHashMap::remove): Ditto. 27 28 * wtf/ListHashSet.h: 29 (WTF::ListHashSet::takeFirst): Added. 30 (WTF::ListHashSet::takeLast): Added. 31 (WTF::ListHashSet::remove): Added a boolean return value, true if something was removed. 32 33 * wtf/WTFThreadData.h: 34 (JSC::IdentifierTable::remove): Use the new remove return value to get rid of most of 35 the code in this function. 36 1 37 2013-09-02 David Kilzer <ddkilzer@apple.com> 2 38 -
trunk/Source/WTF/wtf/HashCountedSet.h
r130612 r154967 1 1 /* 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2008, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 69 69 70 70 // Removes the value, regardless of its count. 71 voidremoveAll(iterator);72 voidremoveAll(const ValueType&);71 bool removeAll(iterator); 72 bool removeAll(const ValueType&); 73 73 74 74 // Clears the whole set. … … 184 184 185 185 template<typename Value, typename HashFunctions, typename Traits> 186 inline voidHashCountedSet<Value, HashFunctions, Traits>::removeAll(const ValueType& value)187 { 188 re moveAll(find(value));189 } 190 191 template<typename Value, typename HashFunctions, typename Traits> 192 inline voidHashCountedSet<Value, HashFunctions, Traits>::removeAll(iterator it)186 inline bool HashCountedSet<Value, HashFunctions, Traits>::removeAll(const ValueType& value) 187 { 188 return removeAll(find(value)); 189 } 190 191 template<typename Value, typename HashFunctions, typename Traits> 192 inline bool HashCountedSet<Value, HashFunctions, Traits>::removeAll(iterator it) 193 193 { 194 194 if (it == end()) 195 return ;195 return false; 196 196 197 197 m_impl.remove(it); 198 return true; 198 199 } 199 200 -
trunk/Source/WTF/wtf/HashMap.h
r151920 r154967 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 107 107 AddResult add(const KeyType&, MappedPassInType); 108 108 109 voidremove(const KeyType&);110 voidremove(iterator);109 bool remove(const KeyType&); 110 bool remove(iterator); 111 111 void clear(); 112 112 … … 381 381 382 382 template<typename T, typename U, typename V, typename W, typename X> 383 inline voidHashMap<T, U, V, W, X>::remove(iterator it)383 inline bool HashMap<T, U, V, W, X>::remove(iterator it) 384 384 { 385 385 if (it.m_impl == m_impl.end()) 386 return ;386 return false; 387 387 m_impl.internalCheckTableConsistency(); 388 388 m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); 389 } 390 391 template<typename T, typename U, typename V, typename W, typename X> 392 inline void HashMap<T, U, V, W, X>::remove(const KeyType& key) 393 { 394 remove(find(key)); 389 return true; 390 } 391 392 template<typename T, typename U, typename V, typename W, typename X> 393 inline bool HashMap<T, U, V, W, X>::remove(const KeyType& key) 394 { 395 return remove(find(key)); 395 396 } 396 397 -
trunk/Source/WTF/wtf/HashSet.h
r153274 r154967 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 89 89 bool add(IteratorType begin, IteratorType end); 90 90 91 voidremove(const ValueType&);92 voidremove(iterator);91 bool remove(const ValueType&); 92 bool remove(iterator); 93 93 void clear(); 94 94 … … 205 205 206 206 template<typename T, typename U, typename V> 207 inline voidHashSet<T, U, V>::remove(iterator it)207 inline bool HashSet<T, U, V>::remove(iterator it) 208 208 { 209 209 if (it.m_impl == m_impl.end()) 210 return ;210 return false; 211 211 m_impl.internalCheckTableConsistency(); 212 212 m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); 213 } 214 215 template<typename T, typename U, typename V> 216 inline void HashSet<T, U, V>::remove(const ValueType& value) 217 { 218 remove(find(value)); 213 return true; 214 } 215 216 template<typename T, typename U, typename V> 217 inline bool HashSet<T, U, V>::remove(const ValueType& value) 218 { 219 return remove(find(value)); 219 220 } 220 221 -
trunk/Source/WTF/wtf/ListHashSet.h
r148921 r154967 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> 4 4 * … … 108 108 const ValueType& first() const; 109 109 void removeFirst(); 110 ValueType takeFirst(); 110 111 111 112 ValueType& last(); 112 113 const ValueType& last() const; 113 114 void removeLast(); 115 ValueType takeLast(); 114 116 115 117 iterator find(const ValueType&); … … 141 143 AddResult insertBefore(iterator, const ValueType&); 142 144 143 voidremove(const ValueType&);144 voidremove(iterator);145 bool remove(const ValueType&); 146 bool remove(iterator); 145 147 void clear(); 146 148 … … 630 632 631 633 template<typename T, size_t inlineCapacity, typename U> 634 inline T ListHashSet<T, inlineCapacity, U>::takeFirst() 635 { 636 T result = first(); 637 removeFirst(); 638 return result; 639 } 640 641 template<typename T, size_t inlineCapacity, typename U> 632 642 inline const T& ListHashSet<T, inlineCapacity, U>::first() const 633 643 { … … 656 666 m_impl.remove(m_tail); 657 667 unlinkAndDelete(m_tail); 668 } 669 670 template<typename T, size_t inlineCapacity, typename U> 671 inline T ListHashSet<T, inlineCapacity, U>::takeLast() 672 { 673 T result = last(); 674 removeLast(); 675 return result; 658 676 } 659 677 … … 762 780 763 781 template<typename T, size_t inlineCapacity, typename U> 764 inline voidListHashSet<T, inlineCapacity, U>::remove(iterator it)782 inline bool ListHashSet<T, inlineCapacity, U>::remove(iterator it) 765 783 { 766 784 if (it == end()) 767 return ;785 return false; 768 786 m_impl.remove(it.node()); 769 787 unlinkAndDelete(it.node()); 770 } 771 772 template<typename T, size_t inlineCapacity, typename U> 773 inline void ListHashSet<T, inlineCapacity, U>::remove(const ValueType& value) 774 { 775 remove(find(value)); 788 return true; 789 } 790 791 template<typename T, size_t inlineCapacity, typename U> 792 inline bool ListHashSet<T, inlineCapacity, U>::remove(const ValueType& value) 793 { 794 return remove(find(value)); 776 795 } 777 796 -
trunk/Source/WTF/wtf/RefPtrHashMap.h
r130612 r154967 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 97 97 AddResult add(RawKeyType, MappedPassInType); 98 98 99 voidremove(const KeyType&);100 voidremove(RawKeyType);101 voidremove(iterator);99 bool remove(const KeyType&); 100 bool remove(RawKeyType); 101 bool remove(iterator); 102 102 void clear(); 103 103 … … 276 276 277 277 template<typename T, typename U, typename V, typename W, typename X> 278 inline voidHashMap<RefPtr<T>, U, V, W, X>::remove(iterator it)278 inline bool HashMap<RefPtr<T>, U, V, W, X>::remove(iterator it) 279 279 { 280 280 if (it.m_impl == m_impl.end()) 281 return ;281 return false; 282 282 m_impl.internalCheckTableConsistency(); 283 283 m_impl.removeWithoutEntryConsistencyCheck(it.m_impl); 284 } 285 286 template<typename T, typename U, typename V, typename W, typename X> 287 inline void HashMap<RefPtr<T>, U, V, W, X>::remove(const KeyType& key) 288 { 289 remove(find(key)); 290 } 291 292 template<typename T, typename U, typename V, typename W, typename X> 293 inline void HashMap<RefPtr<T>, U, V, W, X>::remove(RawKeyType key) 294 { 295 remove(find(key)); 284 return true; 285 } 286 287 template<typename T, typename U, typename V, typename W, typename X> 288 inline bool HashMap<RefPtr<T>, U, V, W, X>::remove(const KeyType& key) 289 { 290 return remove(find(key)); 291 } 292 293 template<typename T, typename U, typename V, typename W, typename X> 294 inline bool HashMap<RefPtr<T>, U, V, W, X>::remove(RawKeyType key) 295 { 296 return remove(find(key)); 296 297 } 297 298 -
trunk/Source/WTF/wtf/WTFThreadData.h
r151578 r154967 37 37 #include <wtf/Threading.h> 38 38 39 // FIXME: This is a temporary layering violation while we move more string code to WTF.39 // FIXME: This is a temporary layering violation until we move more of the string code from JavaScriptCore to WTF. 40 40 namespace JSC { 41 41 … … 45 45 WTF_EXPORT_PRIVATE ~IdentifierTable(); 46 46 47 WTF_EXPORT_PRIVATE HashSet<StringImpl*>::AddResult add(StringImpl* value); 48 template<typename U, typename V> 49 HashSet<StringImpl*>::AddResult add(U value); 47 WTF_EXPORT_PRIVATE HashSet<StringImpl*>::AddResult add(StringImpl*); 48 template<typename U, typename V> HashSet<StringImpl*>::AddResult add(U); 50 49 51 bool remove(StringImpl* r) 52 { 53 HashSet<StringImpl*>::iterator iter = m_table.find(r); 54 if (iter == m_table.end()) 55 return false; 56 m_table.remove(iter); 57 return true; 58 } 50 bool remove(StringImpl* identifier) { return m_table.remove(identifier); } 59 51 60 52 private: -
trunk/Source/WebCore/ChangeLog
r154965 r154967 1 2013-09-02 Darin Adler <darin@apple.com> 2 3 Cut down on double hashing and code needlessly using hash table iterators 4 https://bugs.webkit.org/show_bug.cgi?id=120611 5 6 Reviewed by Andreas Kling. 7 8 Some of these changes are primarily code cleanup, but others could provide 9 a small code size and speed improvement by avoiding extra hashing. 10 11 * Modules/geolocation/Geolocation.cpp: 12 (WebCore::Geolocation::Watchers::find): Use get instead of find. 13 (WebCore::Geolocation::Watchers::remove): Use take instead of find. 14 (WebCore::Geolocation::makeCachedPositionCallbacks): Use the return 15 value from remove to avoid hashing twice. 16 17 * Modules/webaudio/AudioContext.cpp: 18 (WebCore::AudioContext::addAutomaticPullNode): Use the return value from 19 add to avoid hashing twice. 20 (WebCore::AudioContext::removeAutomaticPullNode): Use the return value 21 from remove to avoid hashing twice. 22 23 * Modules/webaudio/AudioNodeInput.cpp: 24 (WebCore::AudioNodeInput::connect): Use the return value from add to avoid 25 hashing twice. 26 (WebCore::AudioNodeInput::disconnect): Use the return value from remove 27 to avoid hashing twice. 28 29 * Modules/webaudio/AudioParam.cpp: 30 (WebCore::AudioParam::connect): Use the return value from add to avoid 31 hashing twice. 32 (WebCore::AudioParam::disconnect): Use the return value from remove to 33 avoid hashing twice. 34 35 * bridge/NP_jsobject.cpp: 36 (ObjectMap::remove): Use remove instead of find/remove. 37 38 * dom/Node.cpp: 39 (WebCore::Node::~Node): Use the return value from remove instead of 40 find/remove. 41 42 * inspector/InspectorProfilerAgent.cpp: 43 (WebCore::InspectorProfilerAgent::removeProfile): Remove needless 44 calls to contains. 45 46 * loader/DocumentLoader.cpp: 47 (WebCore::DocumentLoader::removeSubresourceLoader): Use the return 48 value from remove instead of find/remove. 49 50 * loader/ResourceLoadScheduler.cpp: 51 (WebCore::ResourceLoadScheduler::HostInformation::remove): Use the 52 return value from remove to avoid hashing twice. 53 54 * loader/appcache/ApplicationCacheGroup.cpp: 55 (WebCore::ApplicationCacheGroup::disassociateDocumentLoader): Use 56 remove instead of find/remove. 57 (WebCore::ApplicationCacheGroup::cacheDestroyed): Removed a needless 58 call to contains to avoid hashing twice. It's fine to do the check 59 for an empty hash table unconditionally. 60 61 * page/DOMWindow.cpp: 62 (WebCore::addUnloadEventListener): Eliminated a local variable for clarity. 63 (WebCore::removeUnloadEventListener): Ditto. Also use remove instead 64 of find/remove. 65 (WebCore::removeAllUnloadEventListeners): Ditto. Also use removeAll instead 66 of find/removeAll. 67 (WebCore::addBeforeUnloadEventListener): Ditto. 68 (WebCore::removeBeforeUnloadEventListener): Ditto. 69 (WebCore::removeAllBeforeUnloadEventListeners): Ditto. 70 71 * page/FrameView.cpp: 72 (WebCore::FrameView::removeViewportConstrainedObject): Use the return 73 value from remove to avoid hashing twice. 74 (WebCore::FrameView::removeScrollableArea): Use the return value from 75 remove instead of find/remove. 76 (WebCore::FrameView::containsScrollableArea): Use && instead of an if 77 statement in a way that is idiomatic for this kind of function. 78 79 * page/Page.cpp: 80 (WebCore::Page::addRelevantRepaintedObject): Use the return value from 81 remove instead of find/remove. 82 83 * page/PageGroup.cpp: 84 (WebCore::PageGroup::removeUserScriptsFromWorld): Use remove instead 85 of find/remove. 86 (WebCore::PageGroup::removeUserStyleSheetsFromWorld): Use the return 87 value from remove instead of find/remove. 88 89 * page/PerformanceUserTiming.cpp: 90 (WebCore::clearPeformanceEntries): Removed a needless call to contains. 91 92 * platform/graphics/DisplayRefreshMonitor.cpp: 93 (WebCore::DisplayRefreshMonitor::removeClient): Use the return value 94 from remove instead of find/remove. 95 (WebCore::DisplayRefreshMonitorManager::displayDidRefresh): Use remove 96 instead of find/remove. 97 98 * platform/graphics/blackberry/LayerRenderer.cpp: 99 (WebCore::LayerRenderer::removeLayer): Use the return value from remove 100 instead of find/remove. 101 102 * platform/win/WindowMessageBroadcaster.cpp: 103 (WebCore::WindowMessageBroadcaster::removeListener): Use remove instead 104 of find/remove. It's fine to do the check for an empty hash table unconditionally. 105 106 * plugins/PluginDatabase.cpp: 107 (WebCore::PluginDatabase::removeDisabledPluginFile): Use the return value 108 from remove instead of find/remove. 109 110 * rendering/style/StyleCustomFilterProgramCache.cpp: 111 (WebCore::StyleCustomFilterProgramCache::lookup): Use get instead of find. 112 (WebCore::StyleCustomFilterProgramCache::add): Use contains instead of find 113 in an assertion. 114 (WebCore::StyleCustomFilterProgramCache::remove): Use remove instead of 115 find/remove. 116 117 * svg/SVGCursorElement.cpp: 118 (WebCore::SVGCursorElement::removeClient): Use the return value from remove 119 instead of find/remove. 120 121 * svg/SVGDocumentExtensions.cpp: 122 (WebCore::SVGDocumentExtensions::removeResource): Removed an unneeded call 123 to contains. 124 (WebCore::SVGDocumentExtensions::removeAllTargetReferencesForElement): Use 125 remove instead of find/remove. It's fine to do the check for an empty hash 126 table unconditionally. 127 (WebCore::SVGDocumentExtensions::removeAllElementReferencesForTarget): Use 128 remove instead of find/remove. Also removed unhelpful assertions. One is 129 already done by HashMap, and the other is just checking a basic invariant 130 of every HashMap that doesn't need to be checked. 131 132 * svg/graphics/SVGImageCache.cpp: 133 (WebCore::SVGImageCache::removeClientFromCache): Removed an unneeded call 134 to contains. 135 136 * svg/properties/SVGAnimatedProperty.cpp: 137 (WebCore::SVGAnimatedProperty::~SVGAnimatedProperty): Use the version of 138 remove that takes an iterator rather than the one that takes a key, so 139 we don't need to redo the hashing. 140 1 141 2013-09-02 Andreas Kling <akling@apple.com> 2 142 -
trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp
r154962 r154967 189 189 { 190 190 ASSERT(id > 0); 191 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); 192 if (iter == m_idToNotifierMap.end()) 193 return 0; 194 return iter->value.get(); 191 return m_idToNotifierMap.get(id); 195 192 } 196 193 … … 198 195 { 199 196 ASSERT(id > 0); 200 IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); 201 if (iter == m_idToNotifierMap.end()) 202 return; 203 m_notifierToIdMap.remove(iter->value); 204 m_idToNotifierMap.remove(iter); 197 if (auto notifier = m_idToNotifierMap.take(id)) 198 m_notifierToIdMap.remove(notifier); 205 199 } 206 200 207 201 void Geolocation::Watchers::remove(GeoNotifier* notifier) 208 202 { 209 NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier); 210 if (iter == m_notifierToIdMap.end()) 211 return; 212 m_idToNotifierMap.remove(iter->value); 213 m_notifierToIdMap.remove(iter); 203 if (auto identifier = m_notifierToIdMap.take(notifier)) 204 m_idToNotifierMap.remove(identifier); 214 205 } 215 206 … … 381 372 // If this is a one-shot request, stop it. Otherwise, if the watch still 382 373 // exists, start the service to get updates. 383 if (m_oneShots.contains(notifier)) 384 m_oneShots.remove(notifier); 385 else if (m_watchers.contains(notifier)) { 374 if (!m_oneShots.remove(notifier) && m_watchers.contains(notifier)) { 386 375 if (notifier->hasZeroTimeout() || startUpdating(notifier)) 387 376 notifier->startTimerIfNeeded(); -
trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp
r154962 r154967 913 913 ASSERT(isGraphOwner()); 914 914 915 if (!m_automaticPullNodes.contains(node)) { 916 m_automaticPullNodes.add(node); 915 if (m_automaticPullNodes.add(node).isNewEntry) 917 916 m_automaticPullNodesNeedUpdating = true; 918 }919 917 } 920 918 … … 923 921 ASSERT(isGraphOwner()); 924 922 925 if (m_automaticPullNodes.contains(node)) { 926 m_automaticPullNodes.remove(node); 923 if (m_automaticPullNodes.remove(node)) 927 924 m_automaticPullNodesNeedUpdating = true; 928 }929 925 } 930 926 -
trunk/Source/WebCore/Modules/webaudio/AudioNodeInput.cpp
r149817 r154967 55 55 56 56 // Check if we're already connected to this output. 57 if ( m_outputs.contains(output))57 if (!m_outputs.add(output).isNewEntry) 58 58 return; 59 59 60 60 output->addInput(this); 61 m_outputs.add(output);62 61 changedOutputs(); 63 62 … … 75 74 76 75 // First try to disconnect from "active" connections. 77 if (m_outputs.contains(output)) { 78 m_outputs.remove(output); 76 if (m_outputs.remove(output)) { 79 77 changedOutputs(); 80 78 output->removeInput(this); … … 84 82 85 83 // Otherwise, try to disconnect from disabled connections. 86 if (m_disabledOutputs.contains(output)) { 87 m_disabledOutputs.remove(output); 84 if (m_disabledOutputs.remove(output)) { 88 85 output->removeInput(this); 89 86 node()->deref(AudioNode::RefTypeConnection); // Note: it's important to return immediately after all deref() calls since the node may be deleted. -
trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp
r149817 r154967 173 173 return; 174 174 175 if ( m_outputs.contains(output))175 if (!m_outputs.add(output).isNewEntry) 176 176 return; 177 177 178 178 output->addParam(this); 179 m_outputs.add(output);180 179 changedOutputs(); 181 180 } … … 189 188 return; 190 189 191 if (m_outputs.contains(output)) { 192 m_outputs.remove(output); 190 if (m_outputs.remove(output)) { 193 191 changedOutputs(); 194 192 output->removeParam(this); -
trunk/Source/WebCore/bridge/NP_jsobject.cpp
r153145 r154967 71 71 void remove(RootObject* rootObject) 72 72 { 73 HashMap<RootObject*, JSToNPObjectMap>::iterator iter = m_map.find(rootObject); 74 ASSERT(iter != m_map.end()); 75 m_map.remove(iter); 73 ASSERT(m_map.contains(rootObject)); 74 m_map.remove(rootObject); 76 75 } 77 76 -
trunk/Source/WebCore/dom/Node.cpp
r154962 r154967 337 337 { 338 338 #ifndef NDEBUG 339 HashSet<Node*>::iterator it = ignoreSet.find(this); 340 if (it != ignoreSet.end()) 341 ignoreSet.remove(it); 342 else 339 if (ignoreSet.remove(this)) 343 340 nodeCounter.decrement(); 344 341 #endif -
trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp
r154201 r154967 313 313 unsigned uid = static_cast<unsigned>(rawUid); 314 314 if (type == CPUProfileType) { 315 if (m_profiles.contains(uid)) 316 m_profiles.remove(uid); 315 m_profiles.remove(uid); 317 316 } else if (type == HeapProfileType) { 318 if (m_snapshots.contains(uid)) 319 m_snapshots.remove(uid); 317 m_snapshots.remove(uid); 320 318 } 321 319 } -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r154962 r154967 1312 1312 void DocumentLoader::removeSubresourceLoader(ResourceLoader* loader) 1313 1313 { 1314 ResourceLoaderSet::iterator it = m_subresourceLoaders.find(loader); 1315 if (it == m_subresourceLoaders.end()) 1316 return; 1317 m_subresourceLoaders.remove(it); 1314 if (!m_subresourceLoaders.remove(loader)) 1315 return; 1318 1316 checkLoadComplete(); 1319 1317 if (Frame* frame = m_frame) -
trunk/Source/WebCore/loader/ResourceLoadScheduler.cpp
r154449 r154967 279 279 void ResourceLoadScheduler::HostInformation::remove(ResourceLoader* resourceLoader) 280 280 { 281 if (m_requestsLoading.contains(resourceLoader)) { 282 m_requestsLoading.remove(resourceLoader); 283 return; 284 } 281 if (m_requestsLoading.remove(resourceLoader)) 282 return; 285 283 286 284 for (int priority = ResourceLoadPriorityHighest; priority >= ResourceLoadPriorityLowest; --priority) { -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
r154558 r154967 363 363 void ApplicationCacheGroup::disassociateDocumentLoader(DocumentLoader* loader) 364 364 { 365 HashSet<DocumentLoader*>::iterator it = m_associatedDocumentLoaders.find(loader); 366 if (it != m_associatedDocumentLoaders.end()) 367 m_associatedDocumentLoaders.remove(it); 368 365 m_associatedDocumentLoaders.remove(loader); 369 366 m_pendingMasterResourceLoaders.remove(loader); 370 367 … … 391 388 void ApplicationCacheGroup::cacheDestroyed(ApplicationCache* cache) 392 389 { 393 if (!m_caches.contains(cache))394 return;395 396 390 m_caches.remove(cache); 397 398 391 if (m_caches.isEmpty()) { 399 392 ASSERT(m_associatedDocumentLoaders.isEmpty()); -
trunk/Source/WebCore/page/DOMWindow.cpp
r154962 r154967 176 176 static void addUnloadEventListener(DOMWindow* domWindow) 177 177 { 178 DOMWindowSet& set = windowsWithUnloadEventListeners(); 179 if (set.add(domWindow).isNewEntry) 178 if (windowsWithUnloadEventListeners().add(domWindow).isNewEntry) 180 179 domWindow->disableSuddenTermination(); 181 180 } … … 183 182 static void removeUnloadEventListener(DOMWindow* domWindow) 184 183 { 185 DOMWindowSet& set = windowsWithUnloadEventListeners(); 186 DOMWindowSet::iterator it = set.find(domWindow); 187 if (set.remove(it)) 184 if (windowsWithUnloadEventListeners().remove(domWindow)) 188 185 domWindow->enableSuddenTermination(); 189 186 } … … 191 188 static void removeAllUnloadEventListeners(DOMWindow* domWindow) 192 189 { 193 DOMWindowSet& set = windowsWithUnloadEventListeners(); 194 DOMWindowSet::iterator it = set.find(domWindow); 195 if (it == set.end()) 196 return; 197 set.removeAll(it); 198 domWindow->enableSuddenTermination(); 190 if (windowsWithUnloadEventListeners().removeAll(domWindow)) 191 domWindow->enableSuddenTermination(); 199 192 } 200 193 201 194 static void addBeforeUnloadEventListener(DOMWindow* domWindow) 202 195 { 203 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 204 if (set.add(domWindow).isNewEntry) 196 if (windowsWithBeforeUnloadEventListeners().add(domWindow).isNewEntry) 205 197 domWindow->disableSuddenTermination(); 206 198 } … … 208 200 static void removeBeforeUnloadEventListener(DOMWindow* domWindow) 209 201 { 210 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 211 DOMWindowSet::iterator it = set.find(domWindow); 212 if (set.remove(it)) 202 if (windowsWithBeforeUnloadEventListeners().remove(domWindow)) 213 203 domWindow->enableSuddenTermination(); 214 204 } … … 216 206 static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow) 217 207 { 218 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); 219 DOMWindowSet::iterator it = set.find(domWindow); 220 if (it == set.end()) 221 return; 222 set.removeAll(it); 223 domWindow->enableSuddenTermination(); 208 if (windowsWithBeforeUnloadEventListeners().removeAll(domWindow)) 209 domWindow->enableSuddenTermination(); 224 210 } 225 211 -
trunk/Source/WebCore/page/FrameView.cpp
r154962 r154967 1563 1563 void FrameView::removeViewportConstrainedObject(RenderObject* object) 1564 1564 { 1565 if (m_viewportConstrainedObjects && m_viewportConstrainedObjects->contains(object)) { 1566 m_viewportConstrainedObjects->remove(object); 1565 if (m_viewportConstrainedObjects && m_viewportConstrainedObjects->remove(object)) { 1567 1566 if (Page* page = frame().page()) { 1568 1567 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator()) … … 4061 4060 bool FrameView::removeScrollableArea(ScrollableArea* scrollableArea) 4062 4061 { 4063 if (!m_scrollableAreas) 4064 return false; 4065 4066 ScrollableAreaSet::iterator it = m_scrollableAreas->find(scrollableArea); 4067 if (it == m_scrollableAreas->end()) 4068 return false; 4069 4070 m_scrollableAreas->remove(it); 4071 return true; 4062 return m_scrollableAreas && m_scrollableAreas->remove(scrollableArea); 4072 4063 } 4073 4064 4074 4065 bool FrameView::containsScrollableArea(ScrollableArea* scrollableArea) const 4075 4066 { 4076 if (!m_scrollableAreas) 4077 return false; 4078 return m_scrollableAreas->contains(scrollableArea); 4067 return m_scrollableAreas && m_scrollableAreas->contains(scrollableArea); 4079 4068 } 4080 4069 -
trunk/Source/WebCore/page/Page.cpp
r154795 r154967 1411 1411 // If this object was previously counted as an unpainted object, remove it from that HashSet 1412 1412 // and corresponding Region. FIXME: This doesn't do the right thing if the objects overlap. 1413 HashSet<RenderObject*>::iterator it = m_relevantUnpaintedRenderObjects.find(object); 1414 if (it != m_relevantUnpaintedRenderObjects.end()) { 1415 m_relevantUnpaintedRenderObjects.remove(it); 1413 if (m_relevantUnpaintedRenderObjects.remove(object)) 1416 1414 m_relevantUnpaintedRegion.subtract(snappedPaintRect); 1417 }1418 1415 1419 1416 // Split the relevantRect into a top half and a bottom half. Making sure we have coverage in -
trunk/Source/WebCore/page/PageGroup.cpp
r154658 r154967 366 366 return; 367 367 368 UserScriptMap::iterator it = m_userScripts->find(world); 369 if (it == m_userScripts->end()) 370 return; 371 372 m_userScripts->remove(it); 368 m_userScripts->remove(world); 373 369 } 374 370 … … 379 375 if (!m_userStyleSheets) 380 376 return; 381 382 UserStyleSheetMap::iterator it = m_userStyleSheets->find(world); 383 if (it == m_userStyleSheets->end()) 384 return; 385 386 m_userStyleSheets->remove(it); 377 378 if (!m_userStyleSheets->remove(world)) 379 return; 387 380 388 381 invalidateInjectedStyleSheetCacheInAllFrames(); -
trunk/Source/WebCore/page/PerformanceUserTiming.cpp
r149579 r154967 96 96 } 97 97 98 if (performanceEntryMap.contains(name)) 99 performanceEntryMap.remove(name); 98 performanceEntryMap.remove(name); 100 99 } 101 100 -
trunk/Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp
r154962 r154967 83 83 bool DisplayRefreshMonitor::removeClient(DisplayRefreshMonitorClient* client) 84 84 { 85 DisplayRefreshMonitorClientSet::iterator it = m_clients.find(client); 86 if (it != m_clients.end()) { 87 m_clients.remove(it); 88 return true; 89 } 90 return false; 85 return m_clients.remove(client); 91 86 } 92 87 … … 180 175 { 181 176 if (monitor->shouldBeTerminated()) { 182 DisplayRefreshMonitorMap::iterator it = m_monitors.find(monitor->displayID()); 183 ASSERT(it != m_monitors.end()); 184 m_monitors.remove(it); 177 ASSERT(m_monitors.contains(monitor->displayID())); 178 m_monitors.remove(monitor->displayID()); 185 179 } 186 180 } -
trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
r154701 r154967 511 511 bool LayerRenderer::removeLayer(LayerCompositingThread* layer) 512 512 { 513 LayerSet::iterator iter = m_layers.find(layer); 514 if (iter == m_layers.end()) 515 return false; 516 m_layers.remove(layer); 517 return true; 513 return m_layers.remove(layer); 518 514 } 519 515 -
trunk/Source/WebCore/platform/win/WindowMessageBroadcaster.cpp
r34640 r154967 86 86 void WindowMessageBroadcaster::removeListener(WindowMessageListener* listener) 87 87 { 88 ListenerSet::iterator found = m_listeners.find(listener); 89 if (found == m_listeners.end()) 90 return; 91 92 m_listeners.remove(found); 93 88 m_listeners.remove(listener); 94 89 if (m_listeners.isEmpty()) 95 90 destroy(); -
trunk/Source/WebCore/plugins/PluginDatabase.cpp
r149812 r154967 372 372 bool PluginDatabase::removeDisabledPluginFile(const String& fileName) 373 373 { 374 if (!m_disabledPluginFiles.contains(fileName)) 375 return false; 376 377 m_disabledPluginFiles.remove(fileName); 378 return true; 374 return m_disabledPluginFiles.remove(fileName); 379 375 } 380 376 -
trunk/Source/WebCore/rendering/style/StyleCustomFilterProgramCache.cpp
r146529 r154967 59 59 StyleCustomFilterProgram* StyleCustomFilterProgramCache::lookup(const CustomFilterProgramInfo& programInfo) const 60 60 { 61 CacheMap::const_iterator iter = m_cache.find(programInfo); 62 return iter != m_cache.end() ? iter->value : 0; 61 return m_cache.get(programInfo); 63 62 } 64 63 … … 70 69 void StyleCustomFilterProgramCache::add(StyleCustomFilterProgram* program) 71 70 { 72 CustomFilterProgramInfo key = programCacheKey(program); 73 ASSERT(m_cache.find(key) == m_cache.end()); 74 m_cache.set(key, program); 71 ASSERT(!m_cache.contains(programCacheKey(program))); 72 m_cache.set(programCacheKey(program), program); 75 73 program->setCache(this); 76 74 } … … 78 76 void StyleCustomFilterProgramCache::remove(StyleCustomFilterProgram* program) 79 77 { 80 CacheMap::iterator iter = m_cache.find(programCacheKey(program)); 81 ASSERT(iter != m_cache.end()); 82 m_cache.remove(iter); 78 ASSERT(m_cache.contains(programCacheKey(program))); 79 m_cache.remove(programCacheKey(program)); 83 80 } 84 85 81 86 82 } // namespace WebCore 87 83 88 84 #endif // ENABLE(CSS_SHADERS) 89 -
trunk/Source/WebCore/svg/SVGCursorElement.cpp
r154877 r154967 107 107 void SVGCursorElement::removeClient(SVGElement* element) 108 108 { 109 HashSet<SVGElement*>::iterator it = m_clients.find(element); 110 if (it != m_clients.end()) { 111 m_clients.remove(it); 109 if (m_clients.remove(element)) 112 110 element->cursorElementRemoved(); 113 }114 111 } 115 112 -
trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp
r145333 r154967 76 76 void SVGDocumentExtensions::removeResource(const AtomicString& id) 77 77 { 78 if (id.isEmpty() || !m_resources.contains(id))78 if (id.isEmpty()) 79 79 return; 80 80 … … 323 323 Vector<SVGElement*> toBeRemoved; 324 324 325 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iteratorend = m_elementDependencies.end();326 for ( HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iteratorit = m_elementDependencies.begin(); it != end; ++it) {325 auto end = m_elementDependencies.end(); 326 for (auto it = m_elementDependencies.begin(); it != end; ++it) { 327 327 SVGElement* referencedElement = it->key; 328 HashSet<SVGElement*>* referencingElements = it->value.get(); 329 HashSet<SVGElement*>::iterator setIt = referencingElements->find(referencingElement); 330 if (setIt == referencingElements->end()) 331 continue; 332 333 referencingElements->remove(setIt); 334 if (referencingElements->isEmpty()) 328 HashSet<SVGElement*>& referencingElements = *it->value; 329 referencingElements.remove(referencingElement); 330 if (referencingElements.isEmpty()) 335 331 toBeRemoved.append(referencedElement); 336 332 } … … 368 364 void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* referencedElement) 369 365 { 370 ASSERT(referencedElement); 371 HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elementDependencies.find(referencedElement); 372 if (it == m_elementDependencies.end()) 373 return; 374 ASSERT(it->key == referencedElement); 375 376 m_elementDependencies.remove(it); 366 m_elementDependencies.remove(referencedElement); 377 367 } 378 368 -
trunk/Source/WebCore/svg/graphics/SVGImageCache.cpp
r148175 r154967 48 48 ASSERT(client); 49 49 50 if (m_imageForContainerMap.contains(client)) 51 m_imageForContainerMap.remove(client); 50 m_imageForContainerMap.remove(client); 52 51 } 53 52 -
trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.cpp
r152553 r154967 40 40 { 41 41 // Remove wrapper from cache. 42 Cache* cache = animatedPropertyCache(); 43 const Cache::const_iterator end = cache->end(); 44 for (Cache::const_iterator it = cache->begin(); it != end; ++it) { 42 Cache& cache = *animatedPropertyCache(); 43 for (auto it = cache.begin(), end = cache.end(); it != end; ++it) { 45 44 if (it->value == this) { 46 cache ->remove(it->key);45 cache.remove(it); 47 46 break; 48 47 } -
trunk/Source/WebKit2/ChangeLog
r154963 r154967 1 2013-09-02 Darin Adler <darin@apple.com> 2 3 Cut down on double hashing and code needlessly using hash table iterators 4 https://bugs.webkit.org/show_bug.cgi?id=120611 5 6 Reviewed by Andreas Kling. 7 8 * Platform/CoreIPC/Connection.cpp: 9 (CoreIPC::Connection::waitForMessage): Use take instead of find/remove. 10 11 * UIProcess/WebPreferences.cpp: 12 (WebKit::WebPreferences::removePageGroup): Use the return value from remove 13 instead of find/remove. 14 15 * WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp: 16 (WebKit::GeolocationPermissionRequestManager::cancelRequestForGeolocation): 17 (WebKit::GeolocationPermissionRequestManager::didReceiveGeolocationPermissionDecision): 18 Use take instead of find/remove. 19 20 * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: 21 (WebKit::NetscapePlugin::frameDidFinishLoading): Use take instead of find/remove. 22 (WebKit::NetscapePlugin::frameDidFail): Use take instead of find/remove. 23 24 * WebProcess/WebPage/WebBackForwardListProxy.cpp: 25 (WebKit::WebBackForwardListProxy::removeItem): Use take instead of find/remove. 26 27 * WebProcess/WebPage/WebPage.cpp: 28 (WebKit::WebPage::didFinishCheckingText): Use take instead of get/remove so we 29 hash only once. 30 (WebKit::WebPage::didCancelCheckingText): Ditto. 31 (WebKit::WebPage::stopExtendingIncrementalRenderingSuppression): Use the return 32 value from remove instead of contains/remove so we hash only once. 33 1 34 2013-09-02 Darin Adler <darin@apple.com> 2 35 -
trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp
r154073 r154967 418 418 MutexLocker locker(m_waitForMessageMutex); 419 419 420 HashMap<std::pair<std::pair<StringReference, StringReference>, uint64_t>, OwnPtr<MessageDecoder>>::iterator it = m_waitForMessageMap.find(messageAndDestination); 421 if (it->value) { 422 OwnPtr<MessageDecoder> decoder = it->value.release(); 423 m_waitForMessageMap.remove(it); 424 420 if (OwnPtr<MessageDecoder> decoder = m_waitForMessageMap.take(messageAndDestination)) 425 421 return decoder.release(); 426 }427 422 428 423 // Now we wait. -
trunk/Source/WebKit2/UIProcess/WebPreferences.cpp
r152273 r154967 71 71 void WebPreferences::removePageGroup(WebPageGroup* pageGroup) 72 72 { 73 HashSet<WebPageGroup*>::iterator iter = m_pageGroups.find(pageGroup); 74 if (iter == m_pageGroups.end()) 75 return; 76 77 m_pageGroups.remove(iter); 78 79 if (privateBrowsingEnabled()) { 73 bool didRemovePageGroup = m_pageGroups.remove(pageGroup); 74 if (didRemovePageGroup && privateBrowsingEnabled()) { 80 75 --privateBrowsingPageGroupCount; 81 76 if (!privateBrowsingPageGroupCount) -
trunk/Source/WebKit2/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp
r154142 r154967 60 60 m_idToGeolocationMap.set(geolocationID, geolocation); 61 61 62 63 62 Frame* frame = geolocation->frame(); 64 63 … … 74 73 void GeolocationPermissionRequestManager::cancelRequestForGeolocation(Geolocation* geolocation) 75 74 { 76 GeolocationToIDMap::iterator it = m_geolocationToIDMap.find(geolocation);77 if ( it == m_geolocationToIDMap.end())75 uint64_t geolocationID = m_geolocationToIDMap.take(geolocation); 76 if (!geolocationID) 78 77 return; 79 80 uint64_t geolocationID = it->value;81 m_geolocationToIDMap.remove(it);82 78 m_idToGeolocationMap.remove(geolocationID); 83 79 } … … 85 81 void GeolocationPermissionRequestManager::didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed) 86 82 { 87 IDToGeolocationMap::iterator it = m_idToGeolocationMap.find(geolocationID);88 if ( it == m_idToGeolocationMap.end())83 Geolocation* geolocation = m_idToGeolocationMap.take(geolocationID); 84 if (!geolocation) 89 85 return; 86 m_geolocationToIDMap.remove(geolocation); 90 87 91 Geolocation* geolocation = it->value;92 88 geolocation->setIsAllowed(allowed); 93 94 m_idToGeolocationMap.remove(it);95 m_geolocationToIDMap.remove(geolocation);96 89 } 97 90 -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r149848 r154967 765 765 ASSERT(m_isStarted); 766 766 767 PendingURLNotifyMap::iterator it = m_pendingURLNotifications.find(requestID);768 if ( it == m_pendingURLNotifications.end())767 auto notification = m_pendingURLNotifications.take(requestID); 768 if (notification.first.isEmpty()) 769 769 return; 770 770 771 String url = it->value.first; 772 void* notificationData = it->value.second; 773 774 m_pendingURLNotifications.remove(it); 775 776 NPP_URLNotify(url.utf8().data(), NPRES_DONE, notificationData); 771 NPP_URLNotify(notification.first.utf8().data(), NPRES_DONE, notification.second); 777 772 } 778 773 … … 781 776 ASSERT(m_isStarted); 782 777 783 PendingURLNotifyMap::iterator it = m_pendingURLNotifications.find(requestID);784 if ( it == m_pendingURLNotifications.end())778 auto notification = m_pendingURLNotifications.take(requestID); 779 if (notification.first.isNull()) 785 780 return; 786 787 String url = it->value.first; 788 void* notificationData = it->value.second; 789 790 m_pendingURLNotifications.remove(it); 791 792 NPP_URLNotify(url.utf8().data(), wasCancelled ? NPRES_USER_BREAK : NPRES_NETWORK_ERR, notificationData); 781 782 NPP_URLNotify(notification.first.utf8().data(), wasCancelled ? NPRES_USER_BREAK : NPRES_NETWORK_ERR, notification.second); 793 783 } 794 784 -
trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
r150669 r154967 127 127 void WebBackForwardListProxy::removeItem(uint64_t itemID) 128 128 { 129 IDToHistoryItemMap::iterator it = idToHistoryItemMap().find(itemID);130 if ( it == idToHistoryItemMap().end())129 RefPtr<HistoryItem> item = idToHistoryItemMap().take(itemID); 130 if (!item) 131 131 return; 132 132 133 WebCore::pageCache()->remove(it->value.get()); 134 135 historyItemToIDMap().remove(it->value); 136 idToHistoryItemMap().remove(it); 133 pageCache()->remove(item.get()); 134 historyItemToIDMap().remove(item); 137 135 } 138 136 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r154877 r154967 3958 3958 void WebPage::didFinishCheckingText(uint64_t requestID, const Vector<TextCheckingResult>& result) 3959 3959 { 3960 TextCheckingRequest* request = m_pendingTextCheckingRequestMap.get(requestID);3960 RefPtr<TextCheckingRequest> request = m_pendingTextCheckingRequestMap.take(requestID); 3961 3961 if (!request) 3962 3962 return; 3963 3963 3964 3964 request->didSucceed(result); 3965 m_pendingTextCheckingRequestMap.remove(requestID);3966 3965 } 3967 3966 3968 3967 void WebPage::didCancelCheckingText(uint64_t requestID) 3969 3968 { 3970 TextCheckingRequest* request = m_pendingTextCheckingRequestMap.get(requestID);3969 RefPtr<TextCheckingRequest> request = m_pendingTextCheckingRequestMap.take(requestID); 3971 3970 if (!request) 3972 3971 return; 3973 3972 3974 3973 request->didCancel(); 3975 m_pendingTextCheckingRequestMap.remove(requestID);3976 3974 } 3977 3975 … … 4183 4181 void WebPage::stopExtendingIncrementalRenderingSuppression(unsigned token) 4184 4182 { 4185 if (!m_activeRenderingSuppressionTokens.contains(token)) 4186 return; 4187 4188 m_activeRenderingSuppressionTokens.remove(token); 4183 if (!m_activeRenderingSuppressionTokens.remove(token)) 4184 return; 4185 4189 4186 m_page->mainFrame().view()->setVisualUpdatesAllowedByClient(!shouldExtendIncrementalRenderingSuppression()); 4190 4187 }
Note: See TracChangeset
for help on using the changeset viewer.