-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix copy_str performance 2 #2477
Conversation
Could you elaborate? |
I'll reopen #2475 and close this one since all the discussion is there. |
Actually, I cannot reopen #2475 because the master branch was force-pushed. |
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 PR.
c9eef45
to
dd022b1
Compare
include/fmt/core.h
Outdated
return copy_str_constexpr<Char>(begin, end, out); | ||
} | ||
|
||
template <typename Char, typename InputIt, typename OutputIt, |
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 is probably nitpicky, but since InputIt and OutputIt aren't iterators in this overload, can you rename the template parameters? I keep getting concerned when I see the "* sizeof(OutputIt)" in the call to memcpy below.
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!
dd022b1
to
10905c8
Compare
I understand that we have reached an implementation that suits both of us? |
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.
Two small comments, otherwise looks good.
include/fmt/core.h
Outdated
FMT_CONSTEXPR auto copy_str_constexpr(InputIt begin, InputIt end, OutputIt out) | ||
-> OutputIt { | ||
while (begin != end) *out++ = static_cast<Char>(*begin++); | ||
return out; | ||
} |
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 suggest merging this into the first overload of copy_str
as before. The second overload can continue calling it as copy_str<Char, const Char*, Char*>(...)
.
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 thought it would lead to recursion, but it doesn't
include/fmt/core.h
Outdated
return copy_str_constexpr<Char>(begin, end, out); | ||
} | ||
|
||
template <typename Char, typename Tp, typename Up, |
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.
nit: Tp -> T, Up -> U for consistency with naming conventions in the library.
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.
fix
5825d11
to
91526ae
Compare
91526ae
to
a20dba6
Compare
Thank you! |
Contrary to expectations, optimized overloading is not called