Skip to content
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 println() overloads added in P3142R0 #4672

Merged
merged 12 commits into from
Oct 24, 2024

Conversation

frederick-vs-ja
Copy link
Contributor

Fixes #4630.

  • Add a function __std_print_newline_only_to_unicode_console to the import library to avoid potential branches around WriteConsoleW.
  • Use sputc for non-Unicode new line printing for ostream to reduce potential branches.
  • Use fputc for non-Unicode new line printing for FILE* as the function seems to be the simplest for the purpose in UCRT.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner May 12, 2024 08:04
@StephanTLavavej StephanTLavavej added the performance Must go faster label May 12, 2024
@StephanTLavavej StephanTLavavej self-assigned this May 12, 2024
@StephanTLavavej

This comment was marked as resolved.

stl/inc/ostream Outdated Show resolved Hide resolved
stl/inc/__msvc_filebuf.hpp Outdated Show resolved Hide resolved
stl/src/print.cpp Outdated Show resolved Hide resolved
stl/inc/print Outdated Show resolved Hide resolved
stl/inc/print Outdated Show resolved Hide resolved
stl/inc/ostream Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

Thanks! 😻 I pushed a conflict-free merge with main followed by several refactorings, shrinking the diff from +181 -2 to +115 -10. Originally, this PR looked like it was adding significant complexity, but now I like where it ended up. I'd still like @CaseyCarter to look at this.

@CaseyCarter CaseyCarter removed their assignment Oct 22, 2024
@StephanTLavavej StephanTLavavej self-assigned this Oct 23, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit a2240ab into microsoft:main Oct 24, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for figuring out the surprisingly complicated logic needed to make these functions fast! 🚀 😻 💚

@frederick-vs-ja frederick-vs-ja deleted the optimize-println branch October 24, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Optimize P3142R0 Printing Blank Lines With println()
3 participants