Rewrite str::push_char in rust.#2062
Closed
grahame wants to merge 1 commit intorust-lang:masterfrom
grahame:pushchar
Closed
Rewrite str::push_char in rust.#2062grahame wants to merge 1 commit intorust-lang:masterfrom grahame:pushchar
grahame wants to merge 1 commit intorust-lang:masterfrom
grahame:pushchar
Conversation
Avoid crossing to C to reallocate underlying array when possible, if we must we now only cross once per char (not once per byte.)
Author
|
(Sorry about all the mut_offset calls; I tried using a bind but it was slow. |
Contributor
|
Well, I've gotten sufficiently motivated to improve our various |
Author
|
Great, thanks! I got the idea to use the upcall_vec_grow from marijn on IRC, this is my first exposure to the innards of the runtime. I'll watch your changes with interest to see how I should have done it :-) |
Contributor
|
Integrated. Thanks! 0d5d2e5 is the tweak that I did. It just reuses some existing functions (and some new ones) instead of casting to a vec and poking at the fill and using the upcall. I believe it maintains the same performance characteristics. If you see otherwise let me know. |
Kobzol
pushed a commit
to Kobzol/rust
that referenced
this pull request
Dec 30, 2024
…letest-rustc-args` (rust-lang#2062)
bors
pushed a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 2, 2025
…letest-rustc-args` (rust-lang#2062)
folkertdev
added a commit
to folkertdev/rust
that referenced
this pull request
Mar 16, 2026
ci: update to actions/checkout@v6
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.
Avoid crossing to C to reallocate underlying vec when possible,
if we must we now only cross once per char (not once per byte.)
As str::from_chars calls this method, but first reserves space in the
underlying vec, str::from_chars becomes significantly quicker.
From my testing this is a decent performance win.