-
Notifications
You must be signed in to change notification settings - Fork 1.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 more code bloat issues in <format> #1874
Conversation
Please note that all but the last commit are the same as in #1851 since I couldn't find a way to make a PR relative to another unmerged one. |
this is the correct way to make the PR relative. You'll have to rebase it when #1851 is merged. |
I'd like to benchmark if the array cache type iterator buffer actually helps anything. |
I don't think it helps anything right now, it just opens future optimization opportunities that require more work on the lower (writing) level. |
Also, don't worry about the force-push when rebasing, this is one of the situations where it's reasonable. |
Rebased, switched to |
Ordinarily I'd push changes to address the trivial issues that I found, but then I remembered that #1882 is relative to this PR so I'll be cautious about pushing changes without asking first. I'll go ahead and "approve with suggestions". |
Addressed comments. |
stl/inc/format
Outdated
return _Handler._Ctx.out(); | ||
_OutputIt vformat_to(_OutputIt _Out, const string_view _Fmt, const format_args _Args) { | ||
if constexpr (is_same_v<_OutputIt, _Fmt_it>) { | ||
_Format_handler<char> _Handler(_Out, _Fmt, _Args, _Lazy_locale{}); |
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.
note (no action required): We know _Fmt_it isn't move only, so we don't have to deal with moving it around.
Very minor suggestions and then it looks good to go. We'll probably merge this bound for Dev17, which means we will ship a version of format without it. It's not a problem though because as far as I can tell it's not an ABI break. |
Thanks for fixing this bloated codegen! This will ship in VS 2022 17.0 Preview 2. 🚀 😻 🎉 |
#1851 works around some code bloat issues by "type erasing" the output iterator. This diff fixes the root cause,
vformat_to
, removing the remaining code bloat issue. It also cleans upformat_to
andvformat
by removing explicit buffer handling from there.format_to_n
andformatted_size
continue to use buffers directly as an optimization.This change applies the second fix from P2216 that has been approved by LEWG and LWG and is awaiting plenary. The main change is to remove unnecessary template parameterization of format arguments passed to
vformat_to
.Fixes #1883.