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

Proposal: Improve std::tm formatter for libstdc++ #2577

Closed
phprus opened this issue Oct 31, 2021 · 1 comment
Closed

Proposal: Improve std::tm formatter for libstdc++ #2577

phprus opened this issue Oct 31, 2021 · 1 comment
Labels

Comments

@phprus
Copy link
Contributor

phprus commented Oct 31, 2021

libstdc++ has a non standard facet std::__timepunct. It is used in std::time_put:
https://github.com/gcc-mirror/gcc/blob/2a62b047eca5859142f024c339cd2686635cf5b1/libstdc%2B%2B-v3/include/bits/locale_facets_nonio.tcc#L1175-L1213

When using libstdc++ we can replace the std::time_put facet with std::__timepunct,
which will can format tm into the preallocated memory buffer. This will avoid the std::basic_ostringstream overhead.

std::__timepunct is a part of libstdc++ ABI.

What do you think about this replacement?

@vitaut
Copy link
Contributor

vitaut commented Oct 31, 2021

Thanks for the suggestion but I don't think it's worth using non-standard APIs for this specific case. There might be other ways to optimize locale-specific formatting such as providing a custom stream.

@vitaut vitaut closed this as completed Oct 31, 2021
@vitaut vitaut added the question label Nov 1, 2021
phprus referenced this issue Nov 11, 2021
* Fix unicode test

* Add xchar support to chrono formatter

* Replace strftime with std::time_put

* Add std::locale support to std::tm formatter

* Use predefined names and formats for C-locale

* Performance improvement

* Make locale-independent and C locale formats consistent among platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants