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

Unified Diff: Source/core/dom/CSSSelectorWatch.cpp

Issue 69543002: Abstract away some of the complexity in CSSSelectorWatch by using HashCountedSet (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/CSSSelectorWatch.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/CSSSelectorWatch.cpp
diff --git a/Source/core/dom/CSSSelectorWatch.cpp b/Source/core/dom/CSSSelectorWatch.cpp
index 4f8b78196618cbc793ba124f21adc342e4df95a5..074d6b2ee81255100b0a74761cedb511b8b552cb 100644
--- a/Source/core/dom/CSSSelectorWatch.cpp
+++ b/Source/core/dom/CSSSelectorWatch.cpp
@@ -90,31 +90,24 @@ void CSSSelectorWatch::updateSelectorMatches(const Vector<String>& removedSelect
for (unsigned i = 0; i < removedSelectors.size(); ++i) {
const String& selector = removedSelectors[i];
- HashMap<String, int>::iterator count = m_matchingCallbackSelectors.find(selector);
- if (count == m_matchingCallbackSelectors.end())
+ if (!m_matchingCallbackSelectors.remove(selector))
continue;
- --count->value;
- if (!count->value) {
- shouldUpdateTimer = true;
-
- m_matchingCallbackSelectors.remove(count);
- if (m_addedSelectors.contains(selector))
- m_addedSelectors.remove(selector);
- else
- m_removedSelectors.add(selector);
- }
+
+ // Count reached 0.
+ shouldUpdateTimer = true;
+ if (m_addedSelectors.contains(selector))
eseidel 2013/11/11 22:24:31 Would itr = find(); remove(itr); be "faster"? Do
+ m_addedSelectors.remove(selector);
+ else
+ m_removedSelectors.add(selector);
}
for (unsigned i = 0; i < addedSelectors.size(); ++i) {
const String& selector = addedSelectors[i];
- HashMap<String, int>::iterator count = m_matchingCallbackSelectors.find(selector);
- if (count != m_matchingCallbackSelectors.end()) {
- ++count->value;
+ HashCountedSet<String>::AddResult result = m_matchingCallbackSelectors.add(selector);
+ if (!result.isNewEntry)
continue;
- }
- shouldUpdateTimer = true;
- m_matchingCallbackSelectors.set(selector, 1);
+ shouldUpdateTimer = true;
if (m_removedSelectors.contains(selector))
m_removedSelectors.remove(selector);
else
« no previous file with comments | « Source/core/dom/CSSSelectorWatch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698