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

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

Issue 298253009: Add iterator object to iterate efficiently over an Element's attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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 | « Source/core/css/SelectorChecker.cpp ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DatasetDOMStringMap.cpp
diff --git a/Source/core/dom/DatasetDOMStringMap.cpp b/Source/core/dom/DatasetDOMStringMap.cpp
index adf09b1210c860ef3b7e804cce7cd3b0eb74969e..3ce3d85b57982dd82480c2cc90563499cb2e2b72 100644
--- a/Source/core/dom/DatasetDOMStringMap.cpp
+++ b/Source/core/dom/DatasetDOMStringMap.cpp
@@ -157,11 +157,11 @@ void DatasetDOMStringMap::getNames(Vector<String>& names)
if (!m_element->hasAttributes())
return;
- unsigned length = m_element->attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element->attributeItem(i);
- if (isValidAttributeName(attribute.localName()))
- names.append(convertAttributeNameToPropertyName(attribute.localName()));
+ AttributeIteratorAccessor attributes = m_element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (isValidAttributeName(it->localName()))
+ names.append(convertAttributeNameToPropertyName(it->localName()));
}
}
@@ -170,11 +170,11 @@ String DatasetDOMStringMap::item(const String& name)
if (!m_element->hasAttributes())
return String();
- unsigned length = m_element->attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element->attributeItem(i);
- if (propertyNameMatchesAttributeName(name, attribute.localName()))
- return attribute.value();
+ AttributeIteratorAccessor attributes = m_element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (propertyNameMatchesAttributeName(name, it->localName()))
+ return it->value();
}
return String();
@@ -185,13 +185,12 @@ bool DatasetDOMStringMap::contains(const String& name)
if (!m_element->hasAttributes())
return false;
- unsigned length = m_element->attributeCount();
- for (unsigned i = 0; i < length; i++) {
- const Attribute& attribute = m_element->attributeItem(i);
- if (propertyNameMatchesAttributeName(name, attribute.localName()))
+ AttributeIteratorAccessor attributes = m_element->attributesIterator();
+ AttributeConstIterator end = attributes.end();
+ for (AttributeConstIterator it = attributes.begin(); it != end; ++it) {
+ if (propertyNameMatchesAttributeName(name, it->localName()))
return true;
}
-
return false;
}
« no previous file with comments | « Source/core/css/SelectorChecker.cpp ('k') | Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698