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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index de27731db16336a195d864545acbed8ed457fa16..93df85b4e9c245d58229a8b0be98af02b2e93082 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -407,14 +407,22 @@ SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Element*
return SelectorFailsLocally;
}
-static inline bool containsHTMLSpace(const AtomicString& string)
+template<typename CharType>
+static inline bool containsHTMLSpaceTemplate(const CharType* string, unsigned length)
{
- for (unsigned i = 0; i < string.length(); i++)
- if (isHTMLSpace<UChar>(string[i]))
+ for (unsigned i = 0; i < length; ++i)
+ if (isHTMLSpace<CharType>(string[i]))
return true;
return false;
}
+static inline bool containsHTMLSpace(const AtomicString& string)
+{
+ if (LIKELY(string.is8Bit()))
+ return containsHTMLSpaceTemplate<LChar>(string.characters8(), string.length());
+ return containsHTMLSpaceTemplate<UChar>(string.characters16(), string.length());
+}
+
static bool attributeValueMatches(const Attribute& attributeItem, CSSSelector::Match match, const AtomicString& selectorValue, bool caseSensitive)
{
const AtomicString& value = attributeItem.value();
« 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