Commit 9fb3577d authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Remove inefficiency from HTMLCollection::namedItems()

Remove inefficiency from HTMLCollection::namedItems(). The code was
unnecessarily checking that the pointers were non-null for every iteration of
the for loops. This CL updates the code so that the null check is done only
once.

R=esprehn@chromium.org, adamk@chromium.org

Review URL: https://codereview.chromium.org/337963002

git-svn-id: svn://svn.chromium.org/blink/trunk@176247 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6fd9ca1c
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment