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

Unified Diff: third_party/WebKit/Source/core/dom/MutationObserver.cpp

Issue 2553343002: Avoid WTF::Vector::at() and operator[] in core/dom. (Closed)
Patch Set: Created 4 years 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
Index: third_party/WebKit/Source/core/dom/MutationObserver.cpp
diff --git a/third_party/WebKit/Source/core/dom/MutationObserver.cpp b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
index 42a63b93e6854a65711435eb7eb43992bc897d21..cce4f48601a9aa5e52fd0fdb02c3bb5387cc8297 100644
--- a/third_party/WebKit/Source/core/dom/MutationObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
@@ -75,9 +75,8 @@ void MutationObserver::observe(Node* node,
HashSet<AtomicString> attributeFilter;
if (observerInit.hasAttributeFilter()) {
- const Vector<String>& sequence = observerInit.attributeFilter();
- for (unsigned i = 0; i < sequence.size(); ++i)
- attributeFilter.add(AtomicString(sequence[i]));
+ for (const auto& name : observerInit.attributeFilter())
+ attributeFilter.add(AtomicString(name));
options |= AttributeFilter;
}
@@ -227,8 +226,8 @@ void MutationObserver::deliver() {
if (registration->hasTransientRegistrations())
transientRegistrations.append(registration);
}
- for (size_t i = 0; i < transientRegistrations.size(); ++i)
- transientRegistrations[i]->clearTransientRegistrations();
+ for (const auto& registration : transientRegistrations)
+ registration->clearTransientRegistrations();
if (m_records.isEmpty())
return;
@@ -249,10 +248,10 @@ void MutationObserver::resumeSuspendedObservers() {
MutationObserverVector suspended;
copyToVector(suspendedMutationObservers(), suspended);
- for (size_t i = 0; i < suspended.size(); ++i) {
- if (!suspended[i]->shouldBeSuspended()) {
- suspendedMutationObservers().remove(suspended[i]);
- activateObserver(suspended[i]);
+ for (const auto& observer : suspended) {
+ if (!observer->shouldBeSuspended()) {
+ suspendedMutationObservers().remove(observer);
+ activateObserver(observer);
}
}
}
@@ -263,11 +262,11 @@ void MutationObserver::deliverMutations() {
copyToVector(activeMutationObservers(), observers);
activeMutationObservers().clear();
std::sort(observers.begin(), observers.end(), ObserverLessThan());
- for (size_t i = 0; i < observers.size(); ++i) {
- if (observers[i]->shouldBeSuspended())
- suspendedMutationObservers().add(observers[i]);
+ for (const auto& observer : observers) {
+ if (observer->shouldBeSuspended())
+ suspendedMutationObservers().add(observer);
else
- observers[i]->deliver();
+ observer->deliver();
}
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/FrameRequestCallbackCollection.cpp ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698