-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Use strlen()
3 times instead of custom length check implementations in ustring
#99817
Conversation
Here is a demonstration of the difference in generated bytecode between the two approaches: https://godbolt.org/z/Tjhs9hWr7 ( (the function will likely be inlined since it's defined in the same file) It's unlikely to make a noticeable difference; it's better to view the PR as a clean-up refactor, but it is slightly better. |
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.
strlen()
3 times instead of custom length check implementations in ustring
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.
Code looks good to me.
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.
This should not make any noticeable difference, code looks fine.
331f8c8
to
b3e3e12
Compare
…rlen, adding an implementation for char32_t.
b3e3e12
to
2b39314
Compare
Thanks! |
strlen(char32_t *)
unfortunately does not exist and has to be added. The implementation speed should be the same or slightly better, except for thechar *p_str
case where it may be slightly better now, because the compiler might not previously have realized that it can use the optimizedstrlen
instead of rolling its own loop.