-
Notifications
You must be signed in to change notification settings - Fork 380
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 str_format(…, …, "%d", …)
using templates
#8363
Conversation
I like it. I'm curious if this gets optimized out properly to a direct call for compile time constant format strings |
I checked with all major compilers on Godbolt and this is what I ended up with. It gets optimized out properly for compile-time constant format strings. |
This looks like over optimization. What happens if the string is " %d" or "%d\n" or even any other format like %lld or %u ? |
It doesn't work in this case. What I'd like to avoid is humans having to remember to call
|
Looks good. I prefer this over having a separate |
f62d213
to
5604a2d
Compare
5604a2d
to
267538e
Compare
a1f2e4f
to
2e85310
Compare
This would make the function `str_from_int` unnecessary, at least user-facing. Advantage: User doesn't have to care about `str_from_int`/`str_format` distinction. Disadvantage: We're adding some template programming to `system.h`, potentially slowing all compilation.
2e85310
to
df9980e
Compare
This would make the function
str_from_int
unnecessary, at least user-facing.Advantage: User doesn't have to care about
str_from_int
/str_format
distinction.Disadvantage: We're adding some template programming to
system.h
, potentially slowing all compilation.Checklist