Skip to content
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

optimize toAscii (backport #2693) #3049

Merged
merged 2 commits into from
Sep 30, 2024
Merged

optimize toAscii (backport #2693) #3049

merged 2 commits into from
Sep 30, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 30, 2024

Construct string in lambda to help the compiler optimize the generated code. Also replace transform with normal loop.


This is an automatic backport of pull request #2693 done by Mergify.

GCC is able to see that the branch is useless as it can be done at
compile time. Produces shorter assembly with both -O2 and -O3.

Assign the pointer to the std::string directly and use proper iterators
with std::transform. Also produces shorter assembly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit 22a4b71)
c == 0 was a dead branch because of the way printable ascii was
calculated. Move it up instead.

While at it, replace std::transform with std::replace. Easier to read.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit e1b3dfa)
@mergify mergify bot mentioned this pull request Sep 30, 2024
@kmilos kmilos added this to the v0.28.4 milestone Sep 30, 2024
@kmilos kmilos merged commit 1767c50 into 0.28.x Sep 30, 2024
59 of 61 checks passed
@mergify mergify bot deleted the mergify/bp/0.28.x/pr-2693 branch September 30, 2024 16:38
@kmilos kmilos added the refactoring Cleanup / Simplify code -> more readable / robust label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Cleanup / Simplify code -> more readable / robust
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants