-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add translate function #5212
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
Add translate function #5212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, I just have one little remark, otherwise it looks good to me :)
auto codepoint_haystack = Utf8Proc::UTF8ToCodepoint(input_haystack, sz); | ||
if (to_replace.count(codepoint_haystack) != 0) { | ||
Utf8Proc::CodepointToUtf8(to_replace[codepoint_haystack], c_sz, c); | ||
result.insert(result.end(), c, c + c_sz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can make a pretty decent estimation as to what the size of result will be, can we add a result.reserve(..)
to this before this loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Reserve a enough size for the result to avoid allocate memory frequently.
Thanks! |
It supports unicode. #5156