Changeset 149557 in webkit


Ignore:
Timestamp:
May 4, 2013 8:03:26 AM (11 years ago)
Author:
akling@apple.com
Message:

Remove CSS selector profiler branches from ElementRuleCollector loop.
<http://webkit.org/b/115581>

Reviewed by Antti Koivisto.

Templatize the method so we don't have to check for active inspector frontends on every
pass through the loop.

Time spent in this loop goes down from 0.5% to 0.2% on iTunes Store, WebCore binary size
goes up 480 bytes (sorry Benjamin, I'll make it up to you.)

  • css/ElementRuleCollector.h:
  • css/ElementRuleCollector.cpp:

(WebCore::ElementRuleCollector::collectMatchingRulesForList):
(WebCore::ElementRuleCollector::doCollectMatchingRulesForList):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149553 r149557  
     12013-05-03  Andreas Kling  <akling@apple.com>
     2
     3        Remove CSS selector profiler branches from ElementRuleCollector loop.
     4        <http://webkit.org/b/115581>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Templatize the method so we don't have to check for active inspector frontends on every
     9        pass through the loop.
     10
     11        Time spent in this loop goes down from 0.5% to 0.2% on iTunes Store, WebCore binary size
     12        goes up 480 bytes (sorry Benjamin, I'll make it up to you.)
     13
     14        * css/ElementRuleCollector.h:
     15        * css/ElementRuleCollector.cpp:
     16        (WebCore::ElementRuleCollector::collectMatchingRulesForList):
     17        (WebCore::ElementRuleCollector::doCollectMatchingRulesForList):
     18
    1192013-04-30  Robert Hogan  <robert@webkit.org>
    220
  • trunk/Source/WebCore/css/ElementRuleCollector.cpp

    r149532 r149557  
    404404void ElementRuleCollector::collectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
    405405{
     406    if (UNLIKELY(InspectorInstrumentation::hasFrontends())) {
     407        doCollectMatchingRulesForList<true>(rules, matchRequest, ruleRange);
     408        return;
     409    }
     410    doCollectMatchingRulesForList<false>(rules, matchRequest, ruleRange);
     411}
     412
     413template<bool hasInspectorFrontends>
     414void ElementRuleCollector::doCollectMatchingRulesForList(const Vector<RuleData>* rules, const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
     415{
    406416    if (!rules)
    407417        return;
     
    416426
    417427        StyleRule* rule = ruleData.rule();
    418         InspectorInstrumentationCookie cookie = InspectorInstrumentation::willMatchRule(document(), rule, m_inspectorCSSOMWrappers, document()->styleSheetCollection());
     428        InspectorInstrumentationCookie cookie;
     429        if (hasInspectorFrontends)
     430            cookie = InspectorInstrumentation::willMatchRule(document(), rule, m_inspectorCSSOMWrappers, document()->styleSheetCollection());
    419431        PseudoId dynamicPseudo = NOPSEUDO;
    420432        if (ruleMatches(ruleData, matchRequest.scope, dynamicPseudo)) {
     
    422434            const StylePropertySet* properties = rule->properties();
    423435            if (!properties || (properties->isEmpty() && !matchRequest.includeEmptyRules)) {
    424                 InspectorInstrumentation::didMatchRule(cookie, false);
     436                if (hasInspectorFrontends)
     437                    InspectorInstrumentation::didMatchRule(cookie, false);
    425438                continue;
    426439            }
    427440            // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the only reason this is needed.
    428441            if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin()) {
    429                 InspectorInstrumentation::didMatchRule(cookie, false);
     442                if (hasInspectorFrontends)
     443                    InspectorInstrumentation::didMatchRule(cookie, false);
    430444                continue;
    431445            }
     
    434448            if (dynamicPseudo != NOPSEUDO && m_pseudoStyleRequest.pseudoId == NOPSEUDO) {
    435449                if (m_mode == SelectorChecker::CollectingRules) {
    436                     InspectorInstrumentation::didMatchRule(cookie, false);
     450                    if (hasInspectorFrontends)
     451                        InspectorInstrumentation::didMatchRule(cookie, false);
    437452                    continue;
    438453                }
     
    447462                // Add this rule to our list of matched rules.
    448463                addMatchedRule(&ruleData);
    449                 InspectorInstrumentation::didMatchRule(cookie, true);
     464                if (hasInspectorFrontends)
     465                    InspectorInstrumentation::didMatchRule(cookie, true);
    450466                continue;
    451467            }
    452468        }
    453         InspectorInstrumentation::didMatchRule(cookie, false);
     469        if (hasInspectorFrontends)
     470            InspectorInstrumentation::didMatchRule(cookie, false);
    454471    }
    455472}
  • trunk/Source/WebCore/css/ElementRuleCollector.h

    r149532 r149557  
    9393       
    9494private:
     95    template<bool hasInspectorFrontends>
     96    void doCollectMatchingRulesForList(const Vector<RuleData>*, const MatchRequest&, StyleResolver::RuleRange&);
     97
    9598    const StyleResolver::State& m_state;
    9699    DocumentRuleSets& m_ruleSets;
Note: See TracChangeset for help on using the changeset viewer.