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

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

Issue 307333004: Optimize SelectorChecker's containsHTMLSpace() utility function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add LIKELY() Created 6 years, 6 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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 nextContext.behaviorAtBoundary = behaviorAtBoundary; 400 nextContext.behaviorAtBoundary = behaviorAtBoundary;
401 401
402 nextContext.isSubSelector = false; 402 nextContext.isSubSelector = false;
403 nextContext.elementStyle = 0; 403 nextContext.elementStyle = 0;
404 if (match(nextContext, siblingTraversalStrategy, result) == SelectorMatc hes) 404 if (match(nextContext, siblingTraversalStrategy, result) == SelectorMatc hes)
405 return SelectorMatches; 405 return SelectorMatches;
406 } 406 }
407 return SelectorFailsLocally; 407 return SelectorFailsLocally;
408 } 408 }
409 409
410 template<typename CharType>
411 static inline bool containsHTMLSpaceTemplate(const CharType* string, unsigned le ngth)
412 {
413 for (unsigned i = 0; i < length; ++i)
414 if (isHTMLSpace<CharType>(string[i]))
415 return true;
416 return false;
417 }
418
410 static inline bool containsHTMLSpace(const AtomicString& string) 419 static inline bool containsHTMLSpace(const AtomicString& string)
411 { 420 {
412 for (unsigned i = 0; i < string.length(); i++) 421 if (LIKELY(string.is8Bit()))
413 if (isHTMLSpace<UChar>(string[i])) 422 return containsHTMLSpaceTemplate<LChar>(string.characters8(), string.len gth());
414 return true; 423 return containsHTMLSpaceTemplate<UChar>(string.characters16(), string.length ());
415 return false;
416 } 424 }
417 425
418 static bool attributeValueMatches(const Attribute& attributeItem, CSSSelector::M atch match, const AtomicString& selectorValue, bool caseSensitive) 426 static bool attributeValueMatches(const Attribute& attributeItem, CSSSelector::M atch match, const AtomicString& selectorValue, bool caseSensitive)
419 { 427 {
420 const AtomicString& value = attributeItem.value(); 428 const AtomicString& value = attributeItem.value();
421 if (value.isNull()) 429 if (value.isNull())
422 return false; 430 return false;
423 431
424 switch (match) { 432 switch (match) {
425 case CSSSelector::Exact: 433 case CSSSelector::Exact:
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 return element.focused() && isFrameFocused(element); 1150 return element.focused() && isFrameFocused(element);
1143 } 1151 }
1144 1152
1145 template 1153 template
1146 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const; 1154 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst DOMSiblingTraversalStrategy&, MatchResult*) const;
1147 1155
1148 template 1156 template
1149 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; 1157 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const;
1150 1158
1151 } 1159 }
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