Use perfect forwarding in String::format#2853
Open
herwinw wants to merge 1 commit into
Open
Conversation
seven1m
approved these changes
Dec 17, 2025
7a570a9 to
e755a20
Compare
This means any rvalue references are now moved into the recursive call,
instead of being copied.
The following example script:
```c++
TM::String foo() { return "foo"; }
TM::String bar() { return "bar"; }
int main() {
TM::String::format("1={}, 2={}", foo(), bar()).print();
return 0;
}
```
Showed about 1k operations in valgrind less with this patch (on a total
of 1.9M operations, so don't expect miracles).
e755a20 to
33806a0
Compare
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 means any rvalue references are now moved into the recursive call, instead of being copied.
The following example script:
Showed about 1k operations in valgrind less with this patch (on a total of 1.9M operations, so don't expect miracles).