Script: len,is_empty and match for DOMString#39866
Merged
jdm merged 4 commits intoservo:mainfrom Oct 23, 2025
Merged
Conversation
2549527 to
bf76566
Compare
Member
|
I've skimmed this PR and it's promising! I'm not convinced by the match macro yet; have you checked what the impact is on code size? I hope to finish reviewing these changes this weekend. |
jdm
requested changes
Oct 20, 2025
We replace is_empty, len with more efficient methods based on the underlying bytes. Additionally, we introduce `match_domstring_ascii!` macro to efficiently match &str in ascii with the domstring without having to convert. Signed-off-by: Narfinger <[email protected]>
Signed-off-by: Narfinger <[email protected]>
bf76566 to
f9c13b5
Compare
Signed-off-by: Narfinger <[email protected]>
f9c13b5 to
eb87024
Compare
Contributor
Author
|
Production build size increases from 113_970_968 to 113_975_664 and increase in 4696 bytes. |
jdm
reviewed
Oct 22, 2025
Signed-off-by: Narfinger <[email protected]>
jdm
approved these changes
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces the implementation of is_empty and len with more efficient representation without conversion
and allocation based on the underlying bytes.
For this we use a new view, EncodedBytesView.
Additionally, we implement a new macro
match_domstring_ascii!which allows simple match clausesmatching ascii strings with DOMStrings without conversion/allocation.
The macro will panic in debug builds if the strings are non-ascii but will not match all DOMStrings correctly.
We replaced the usage of
DOMString::str()in many places with this macro.Testing: len and is_empty were already covered by tests. match_domstring_ascii! has more unit tests added with this PR.