Index: Source/core/dom/ElementData.h |
diff --git a/Source/core/dom/ElementData.h b/Source/core/dom/ElementData.h |
index b7c36f097a53720d0e80ec561c4a7e6ceb3c81ff..a5ffabf0964116ed689aa6706aceb07d62469c2a 100644 |
--- a/Source/core/dom/ElementData.h |
+++ b/Source/core/dom/ElementData.h |
@@ -185,7 +185,9 @@ inline const Attribute* ElementData::attributeBase() const |
inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool shouldIgnoreCase) const |
{ |
const Attribute* begin = attributeBase(); |
- for (unsigned i = 0; i < length(); ++i) { |
+ // Cache length for performance as ElementData::length() contains a conditional branch. |
+ unsigned len = length(); |
+ for (unsigned i = 0; i < len; ++i) { |
const Attribute& attribute = begin[i]; |
if (attribute.name().matchesPossiblyIgnoringCase(name, shouldIgnoreCase)) |
return i; |
@@ -197,6 +199,7 @@ inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool |
// can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not). |
inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const |
{ |
+ // Cache length for performance as ElementData::length() contains a conditional branch. |
unsigned len = length(); |
bool doSlowCheck = shouldIgnoreAttributeCase; |