Title: [293123] trunk/Source/WebCore
- Revision
- 293123
- Author
- [email protected]
- Date
- 2022-04-20 15:11:20 -0700 (Wed, 20 Apr 2022)
Log Message
Avoid call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() in the common case
https://bugs.webkit.org/show_bug.cgi?id=239545
Reviewed by Sam Weinig.
The call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() shows in Speedometer profiles
even though input tags are already lowercase, simply because the function needs to iterate over the string to determine
that it is all lowercase. In the common case though, we can leverage the fact that all known HTML element tags are
lowercase to avoid the call to convertToASCIILowercase(). This is because HTMLElement::localName() returns one of the
tags defined in HTMLNames.h (for known HTML elements), all of which are lowercase.
* css/SelectorFilter.cpp:
(WebCore::SelectorFilter::collectElementIdentifierHashes):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (293122 => 293123)
--- trunk/Source/WebCore/ChangeLog 2022-04-20 22:09:28 UTC (rev 293122)
+++ trunk/Source/WebCore/ChangeLog 2022-04-20 22:11:20 UTC (rev 293123)
@@ -1,5 +1,21 @@
2022-04-20 Chris Dumez <[email protected]>
+ Avoid call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() in the common case
+ https://bugs.webkit.org/show_bug.cgi?id=239545
+
+ Reviewed by Sam Weinig.
+
+ The call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() shows in Speedometer profiles
+ even though input tags are already lowercase, simply because the function needs to iterate over the string to determine
+ that it is all lowercase. In the common case though, we can leverage the fact that all known HTML element tags are
+ lowercase to avoid the call to convertToASCIILowercase(). This is because HTMLElement::localName() returns one of the
+ tags defined in HTMLNames.h (for known HTML elements), all of which are lowercase.
+
+ * css/SelectorFilter.cpp:
+ (WebCore::SelectorFilter::collectElementIdentifierHashes):
+
+2022-04-20 Chris Dumez <[email protected]>
+
Add missing WTFMove() in MIMETypeRegistryThreadGlobalData()
https://bugs.webkit.org/show_bug.cgi?id=239565
Modified: trunk/Source/WebCore/css/SelectorFilter.cpp (293122 => 293123)
--- trunk/Source/WebCore/css/SelectorFilter.cpp 2022-04-20 22:09:28 UTC (rev 293122)
+++ trunk/Source/WebCore/css/SelectorFilter.cpp 2022-04-20 22:11:20 UTC (rev 293123)
@@ -47,7 +47,8 @@
void SelectorFilter::collectElementIdentifierHashes(const Element& element, Vector<unsigned, 4>& identifierHashes)
{
- AtomString tagLowercaseLocalName = element.localName().convertToASCIILowercase();
+ AtomString tagLowercaseLocalName = LIKELY(element.isHTMLElement() && !element.isUnknownElement()) ? element.localName() : element.localName().convertToASCIILowercase();
+ ASSERT(tagLowercaseLocalName == tagLowercaseLocalName.convertToASCIILowercase());
identifierHashes.append(tagLowercaseLocalName.impl()->existingHash() * TagNameSalt);
auto& id = element.idForStyleResolution();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes