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

Simplify CSSSelector::isAttributeSelector() by not checking each Match type

Simplify CSSSelector::isAttributeSelector() by not checking each Match type
explicitly and reordering the Match enum instead so that the attribute
selector match type are contiguous and at the end of the enum. This way, the
check can become (m_match >= FirstAttributeSelectorMatch).

This optimization is similar to the one we already use in CollectionType.h
for collection types. isAttributeSelector() is called from
SelectorChecker::checkOne() which is hot code.

I see a ~2% progression on Dromaeo's cssquery-jquery:
http://dromaeo.com/?id=222514,222518

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175632 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6d0ceef9
......@@ -110,16 +110,17 @@ namespace WebCore {
Tag, // Example: div
Id, // Example: #id
Class, // example: .class
PseudoClass, // Example: :nth-child(2)
PseudoElement, // Example: ::first-line
PagePseudoClass, // ??
Exact, // Example: E[foo="bar"]
Set, // Example: E[foo]
List, // Example: E[foo~="bar"]
Hyphen, // Example: E[foo|="bar"]
PseudoClass, // Example: :nth-child(2)
PseudoElement, // Example: ::first-line
List, // Example: E[foo~="bar"]
Contain, // css3: E[foo*="bar"]
Begin, // css3: E[foo^="bar"]
End, // css3: E[foo$="bar"]
PagePseudoClass // ??
FirstAttributeSelectorMatch = Exact,
};
enum Relation {
......@@ -402,13 +403,7 @@ inline bool CSSSelector::isSiblingSelector() const
inline bool CSSSelector::isAttributeSelector() const
{
return m_match == CSSSelector::Exact
|| m_match == CSSSelector::Set
|| m_match == CSSSelector::List
|| m_match == CSSSelector::Hyphen
|| m_match == CSSSelector::Contain
|| m_match == CSSSelector::Begin
|| m_match == CSSSelector::End;
return m_match >= FirstAttributeSelectorMatch;
}
inline bool CSSSelector::isContentPseudoElement() const
......
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