Repository navigation
script: Allow DOMString to convert efficiently from static strings - #47479
Merged
Merged
Conversation
Narfinger
force-pushed
the
static-domstring
branch
from
August 24, 2026 13:26
28e1b87 to
8a13c4c
Compare
yezhizhen
self-requested a review
August 25, 2026 08:10
yezhizhen
previously requested changes
Aug 25, 2026
yezhizhen
left a comment
Member
There was a problem hiding this comment.
We have to adapt this, otherwise we fall into Latin1 encoding:
servo/components/script_bindings/domstring.rs
Lines 381 to 387 in 1ed4640
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Contributor
Author
|
Oh good find! |
TimvdLippe
approved these changes
Aug 25, 2026
TimvdLippe
left a comment
Contributor
There was a problem hiding this comment.
Mechanical changes LGTM. Maybe we can improve some linter to make this more obvious to future usages? I think this is an easy thing to backslide
Member
|
We should add some tests for the new variant and fn. Similar to those already in the file. |
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Contributor
Author
|
Added some tests. |
TimvdLippe
dismissed
yezhizhen’s stale review
August 26, 2026 08:11
Re-requesting review button doesn't work, but tests have been added.
yezhizhen
approved these changes
Aug 26, 2026
RichardTjokroutomo
pushed a commit
to RichardTjokroutomo/servo
that referenced
this pull request
Oct 6, 2026
…ervo#47479) We allow DOMStrings to efficiently convert from static strings by introducing the DOMString::from_static method. We achieve this by having another entry in our enum that holds the static string. This will safe on memory for DOMStrings that never change. The rest of the changes are mechanical and the static lifetime guarantees that the string will never go out of scope. Adapted the original idea from in house fork. Testing: WPT tests should find anything that breaks. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Psychpsyo
pushed a commit
to Psychpsyo/servo
that referenced
this pull request
Oct 12, 2026
…ervo#47479) We allow DOMStrings to efficiently convert from static strings by introducing the DOMString::from_static method. We achieve this by having another entry in our enum that holds the static string. This will safe on memory for DOMStrings that never change. The rest of the changes are mechanical and the static lifetime guarantees that the string will never go out of scope. Adapted the original idea from in house fork. Testing: WPT tests should find anything that breaks. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
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.
We allow DOMStrings to efficiently convert from static strings by introducing the DOMString::from_static method.
We achieve this by having another entry in our enum that holds the static string. This will safe on memory for DOMStrings that never change.
The rest of the changes are mechanical and the static lifetime guarantees that the string will never go out of scope.
Adapted the original idea from in house fork.
Testing: WPT tests should find anything that breaks.