| Index: Source/core/css/StylePropertySet.cpp
|
| diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
|
| index 65c8e1f4d8c7bc7071d79c3b6d40990cd749a944..904c8159e852d4f1313e0557b4a4c0381b0b057f 100644
|
| --- a/Source/core/css/StylePropertySet.cpp
|
| +++ b/Source/core/css/StylePropertySet.cpp
|
| @@ -500,31 +500,25 @@ CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration()
|
| return m_cssomWrapper.get();
|
| }
|
|
|
| +int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
|
| +{
|
| + const CSSProperty* begin = m_propertyVector.data();
|
| + const CSSProperty* end = begin + m_propertyVector.size();
|
| + // Convert here propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
|
| + // the compiler converting it to an int multiple times in the loop.
|
| + uint16_t id = static_cast<uint16_t>(propertyID);
|
|
|
| -class CSSPropertyIDComparer {
|
| -public:
|
| - explicit CSSPropertyIDComparer(CSSPropertyID propertyID)
|
| - : m_propertyID(static_cast<uint16_t>(propertyID)) { }
|
| - bool operator()(const CSSProperty& property) const
|
| + auto compare = [propertyID, id](const CSSProperty& property) -> bool
|
| {
|
| - if (property.metadata().m_propertyID == m_propertyID) {
|
| + if (property.metadata().m_propertyID == id) {
|
| // Only enabled properties should be part of the style.
|
| - ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID()));
|
| + ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID));
|
| return true;
|
| }
|
| return false;
|
| - }
|
| -
|
| -private:
|
| - CSSPropertyID propertyID() const { return static_cast<CSSPropertyID>(m_propertyID); }
|
| - uint16_t m_propertyID; // Store as uint16_t to avoid casts while comparing.
|
| -};
|
| + };
|
|
|
| -int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
|
| -{
|
| - const CSSProperty* begin = m_propertyVector.data();
|
| - const CSSProperty* end = begin + m_propertyVector.size();
|
| - const CSSProperty* it = std::find_if(begin, end, CSSPropertyIDComparer(propertyID));
|
| + const CSSProperty* it = std::find_if(begin, end, compare);
|
|
|
| return (it == end) ? -1 : it - begin;
|
| }
|
|
|