Changeset 190842 in webkit
- Timestamp:
- Oct 10, 2015 2:13:15 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r190841 r190842 1 2015-10-10 Andreas Kling <akling@apple.com> 2 3 Reduce pointless malloc traffic in ElementRuleCollector. 4 <https://webkit.org/b/150003> 5 6 Reviewed by Antti Koivisto. 7 8 Don't use a unique_ptr for the m_matchedRules vector in ElementRuleCollector. 9 This is one of our heaviest sources of transient allocations, with ~88000 10 malloc/free pairs on loading theverge.com. 11 12 * css/ElementRuleCollector.cpp: 13 (WebCore::ElementRuleCollector::addMatchedRule): 14 (WebCore::ElementRuleCollector::clearMatchedRules): 15 (WebCore::ElementRuleCollector::sortAndTransferMatchedRules): 16 (WebCore::ElementRuleCollector::sortMatchedRules): 17 (WebCore::ElementRuleCollector::hasAnyMatchingRules): 18 * css/ElementRuleCollector.h: 19 (WebCore::ElementRuleCollector::hasMatchedRules): 20 1 21 2015-10-10 Dan Bernstein <mitz@apple.com> 2 22 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r190680 r190842 90 90 inline void ElementRuleCollector::addMatchedRule(const MatchedRule& matchedRule) 91 91 { 92 if (!m_matchedRules) 93 m_matchedRules = std::make_unique<Vector<MatchedRule, 32>>(); 94 m_matchedRules->append(matchedRule); 92 m_matchedRules.append(matchedRule); 95 93 } 96 94 97 95 void ElementRuleCollector::clearMatchedRules() 98 96 { 99 if (!m_matchedRules) 100 return; 101 m_matchedRules->clear(); 97 m_matchedRules.clear(); 102 98 } 103 99 … … 167 163 void ElementRuleCollector::sortAndTransferMatchedRules() 168 164 { 169 if ( !m_matchedRules || m_matchedRules->isEmpty())165 if (m_matchedRules.isEmpty()) 170 166 return; 171 167 172 168 sortMatchedRules(); 173 169 174 Vector<MatchedRule, 32>& matchedRules = *m_matchedRules;175 170 if (m_mode == SelectorChecker::Mode::CollectingRules) { 176 for (const MatchedRule& matchedRule : m atchedRules)171 for (const MatchedRule& matchedRule : m_matchedRules) 177 172 m_matchedRuleList.append(matchedRule.ruleData->rule()); 178 173 return; … … 180 175 181 176 // Now transfer the set of matched rules over to our list of declarations. 182 for (const MatchedRule& matchedRule : m atchedRules) {177 for (const MatchedRule& matchedRule : m_matchedRules) { 183 178 if (m_style && matchedRule.ruleData->containsUncommonAttributeSelector()) 184 179 m_style->setUnique(); … … 394 389 void ElementRuleCollector::sortMatchedRules() 395 390 { 396 ASSERT(m_matchedRules); 397 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules); 391 std::sort(m_matchedRules.begin(), m_matchedRules.end(), compareRules); 398 392 } 399 393 … … 454 448 collectMatchingRules(MatchRequest(ruleSet), ruleRange); 455 449 456 return m_matchedRules && !m_matchedRules->isEmpty();450 return !m_matchedRules.isEmpty(); 457 451 } 458 452 -
trunk/Source/WebCore/css/ElementRuleCollector.h
r190680 r190842 71 71 const Vector<RefPtr<StyleRule>>& matchedRuleList() const; 72 72 73 bool hasMatchedRules() const { return m_matchedRules && !m_matchedRules->isEmpty(); }73 bool hasMatchedRules() const { return !m_matchedRules.isEmpty(); } 74 74 void clearMatchedRules(); 75 75 … … 104 104 bool m_canUseFastReject; 105 105 106 std::unique_ptr<Vector<MatchedRule, 32>> m_matchedRules;106 Vector<MatchedRule, 64> m_matchedRules; 107 107 108 108 // Output.
Note: See TracChangeset
for help on using the changeset viewer.