Skip to content

🍒[cxx-interop] Faster std::string initialization from String #73413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2024

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented May 3, 2024

Explanation: Instead of appending characters one-by-one, which resizes the resulting string multiple times, let's reserve the required number of bytes beforehand.
Scope: This changes std.string(_: Swift.String) convenience initializer in the overlay for CxxStdlib.
Risk: Low, only affects the overlay for the C++ stdlib.
Testing: Already covered by existing compiler tests. There is an improvement in performance tests results.
Issue: rdar://127423949
Reviewer: @stephentyrone

Original PR: #72268

Instead of appending characters one-by-one, which resizes the resulting string multiple times, let's reserve the required number of bytes beforehand.

rdar://127423949
(cherry picked from commit 4513ca2)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label May 3, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan changed the title [cxx-interop] Faster std::string initialization from String 🍒[cxx-interop] Faster std::string initialization from String May 3, 2024
@egorzhdan egorzhdan marked this pull request as ready for review May 7, 2024 13:09
@egorzhdan egorzhdan requested a review from a team as a code owner May 7, 2024 13:09
@egorzhdan egorzhdan merged commit 808a64c into release/6.0 May 7, 2024
@egorzhdan egorzhdan deleted the egorzhdan/6.0-std-string-reserve branch May 7, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants