Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: Source/core/css/RuleFeature.cpp

Issue 172993002: Removed O(n!) traversal of selectors for selectorList. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 ASSERT(!maxDirectAdjacentSelectors); 206 ASSERT(!maxDirectAdjacentSelectors);
207 } 207 }
208 208
209 void RuleFeatureSet::collectFeaturesFromSelectorList(const CSSSelectorList* sele ctorList, RuleFeatureSet::FeatureMetadata& metadata, SelectorFeatureCollectionMo de collectionMode) 209 void RuleFeatureSet::collectFeaturesFromSelectorList(const CSSSelectorList* sele ctorList, RuleFeatureSet::FeatureMetadata& metadata, SelectorFeatureCollectionMo de collectionMode)
210 { 210 {
211 if (!selectorList) 211 if (!selectorList)
212 return; 212 return;
213 213
214 for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector)) { 214 for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector))
215 for (const CSSSelector* subSelector = selector; subSelector; subSelector = subSelector->tagHistory()) 215 collectFeaturesFromSelector(*selector, metadata, collectionMode);
216 collectFeaturesFromSelector(*subSelector, metadata, collectionMode);
217 }
218 } 216 }
219 217
220 void RuleFeatureSet::FeatureMetadata::add(const FeatureMetadata& other) 218 void RuleFeatureSet::FeatureMetadata::add(const FeatureMetadata& other)
221 { 219 {
222 usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules; 220 usesFirstLineRules = usesFirstLineRules || other.usesFirstLineRules;
223 maxDirectAdjacentSelectors = std::max(maxDirectAdjacentSelectors, other.maxD irectAdjacentSelectors); 221 maxDirectAdjacentSelectors = std::max(maxDirectAdjacentSelectors, other.maxD irectAdjacentSelectors);
224 222
225 HashSet<AtomicString>::const_iterator end = other.idsInRules.end(); 223 HashSet<AtomicString>::const_iterator end = other.idsInRules.end();
226 for (HashSet<AtomicString>::const_iterator it = other.idsInRules.begin(); it != end; ++it) 224 for (HashSet<AtomicString>::const_iterator it = other.idsInRules.begin(); it != end; ++it)
227 idsInRules.add(*it); 225 idsInRules.add(*it);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 element->setNeedsStyleRecalc(LocalStyleChange); 422 element->setNeedsStyleRecalc(LocalStyleChange);
425 423
426 invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize); 424 invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
427 element->clearChildNeedsStyleInvalidation(); 425 element->clearChildNeedsStyleInvalidation();
428 element->clearNeedsStyleInvalidation(); 426 element->clearNeedsStyleInvalidation();
429 427
430 return thisElementNeedsStyleRecalc; 428 return thisElementNeedsStyleRecalc;
431 } 429 }
432 430
433 } // namespace WebCore 431 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698