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

Unified Diff: Source/core/html/HTMLCollection.cpp

Issue 337963002: Remove inefficiency from HTMLCollection::namedItems() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLCollection.cpp
diff --git a/Source/core/html/HTMLCollection.cpp b/Source/core/html/HTMLCollection.cpp
index 83a79e47374c7e1366ccccaf69d4636b31a4095a..451a8870265b48945c6505857bb5f823b496c0b5 100644
--- a/Source/core/html/HTMLCollection.cpp
+++ b/Source/core/html/HTMLCollection.cpp
@@ -507,14 +507,14 @@ void HTMLCollection::namedItems(const AtomicString& name, WillBeHeapVector<RefPt
updateIdNameCache();
const NamedItemCache& cache = namedItemCache();
- WillBeHeapVector<RawPtrWillBeMember<Element> >* idResults = cache.getElementsById(name);
- WillBeHeapVector<RawPtrWillBeMember<Element> >* nameResults = cache.getElementsByName(name);
-
- for (unsigned i = 0; idResults && i < idResults->size(); ++i)
- result.append(idResults->at(i));
-
- for (unsigned i = 0; nameResults && i < nameResults->size(); ++i)
- result.append(nameResults->at(i));
+ if (WillBeHeapVector<RawPtrWillBeMember<Element> >* idResults = cache.getElementsById(name)) {
+ for (unsigned i = 0; i < idResults->size(); ++i)
+ result.append(idResults->at(i));
+ }
+ if (WillBeHeapVector<RawPtrWillBeMember<Element> >* nameResults = cache.getElementsByName(name)) {
+ for (unsigned i = 0; i < nameResults->size(); ++i)
+ result.append(nameResults->at(i));
+ }
}
HTMLCollection::NamedItemCache::NamedItemCache()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698