Bug 239545 - Avoid call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() in the common case
Summary: Avoid call to convertToASCIILowercase() in SelectorFilter::collectElementIden...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-20 09:08 PDT by Chris Dumez
Modified: 2022-04-20 19:08 PDT (History)
11 users (show)

See Also:


Attachments
Patch (2.24 KB, patch)
2022-04-20 09:12 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-04-20 09:08:45 PDT
Avoid call to convertToASCIILowercase() in SelectorFilter::collectElementIdentifierHashes() in the common case.
Comment 1 Chris Dumez 2022-04-20 09:12:51 PDT
Created attachment 457993 [details]
Patch
Comment 2 Sam Weinig 2022-04-20 14:42:49 PDT
Comment on attachment 457993 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457993&action=review

> Source/WebCore/css/SelectorFilter.cpp:50
> +    AtomString tagLowercaseLocalName = LIKELY(element.isHTMLElement() && !element.isUnknownElement()) ? element.localName() : element.localName().convertToASCIILowercase();

A comment explaining this assumption would be useful even with the assert.
Comment 3 EWS 2022-04-20 15:12:34 PDT
Committed r293123 (249826@main): <https://commits.webkit.org/249826@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 457993 [details].
Comment 4 Radar WebKit Bug Importer 2022-04-20 15:13:29 PDT
<rdar://problem/92054703>
Comment 5 Darin Adler 2022-04-20 17:44:46 PDT
Comment on attachment 457993 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=457993&action=review

>> Source/WebCore/css/SelectorFilter.cpp:50
>> +    AtomString tagLowercaseLocalName = LIKELY(element.isHTMLElement() && !element.isUnknownElement()) ? element.localName() : element.localName().convertToASCIILowercase();
> 
> A comment explaining this assumption would be useful even with the assert.

The classic way to do this is to write a function named localNameIsKnownToBeLowercase or localNameMayContainUppercaseASCII. Then that function is the perfect place for the comment explaining why the rule is correct, and here the code is more obviously correct.
Comment 6 Chris Dumez 2022-04-20 18:10:49 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 457993 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457993&action=review
> 
> >> Source/WebCore/css/SelectorFilter.cpp:50
> >> +    AtomString tagLowercaseLocalName = LIKELY(element.isHTMLElement() && !element.isUnknownElement()) ? element.localName() : element.localName().convertToASCIILowercase();
> > 
> > A comment explaining this assumption would be useful even with the assert.
> 
> The classic way to do this is to write a function named
> localNameIsKnownToBeLowercase or localNameMayContainUppercaseASCII. Then
> that function is the perfect place for the comment explaining why the rule
> is correct, and here the code is more obviously correct.

Oh, I missed Sam's comment before landing. Sorry about that. I'll follow-up.
Comment 7 Chris Dumez 2022-04-20 18:52:27 PDT
0.38% progression on Speedometer on Intel, neutral on Apple Silicon.
Comment 8 Chris Dumez 2022-04-20 19:08:43 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 457993 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=457993&action=review
> 
> >> Source/WebCore/css/SelectorFilter.cpp:50
> >> +    AtomString tagLowercaseLocalName = LIKELY(element.isHTMLElement() && !element.isUnknownElement()) ? element.localName() : element.localName().convertToASCIILowercase();
> > 
> > A comment explaining this assumption would be useful even with the assert.
> 
> The classic way to do this is to write a function named
> localNameIsKnownToBeLowercase or localNameMayContainUppercaseASCII. Then
> that function is the perfect place for the comment explaining why the rule
> is correct, and here the code is more obviously correct.

Done in <https://commits.webkit.org/r293138>.