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

Replacing snprintf-based hex float formatter with internal implementation #3179

Merged
merged 2 commits into from
Nov 24, 2022

Conversation

phprus
Copy link
Contributor

@phprus phprus commented Nov 13, 2022

  1. Replacing snprintf-based hex float formatter with internal implementation.
  2. Add missing env CTEST_OUTPUT_ON_FAILURE.
  3. Enable C++17 tests on macOS for simplify hex float tests.

@phprus
Copy link
Contributor Author

phprus commented Nov 13, 2022

Benchmark:
https://github.com/phprus/fmt-bench/tree/hexfloat-1

MacbookPro M1 Max:

  • Default format string: without changes.
  • Compiled format string: ~3 times faster.

@phprus phprus force-pushed the hexfloat-1 branch 3 times, most recently from 7bdac5c to 8dbd9fd Compare November 14, 2022 08:30
Copy link
Contributor

@vitaut vitaut left a 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! Overall looks great, a few minor comments inline. Also please move the build config changes into a separate PR.

include/fmt/format.h Outdated Show resolved Hide resolved
include/fmt/format.h Outdated Show resolved Hide resolved
test/format-test.cc Outdated Show resolved Hide resolved
test/format-test.cc Outdated Show resolved Hide resolved
@phprus phprus mentioned this pull request Nov 16, 2022
@phprus
Copy link
Contributor Author

phprus commented Nov 16, 2022

@vitaut CI PR: #3188
I will do rebase this PR after the merge PR #3188

@phprus phprus marked this pull request as draft November 16, 2022 18:31
@phprus
Copy link
Contributor Author

phprus commented Nov 18, 2022

@vitaut, Rebased.

@phprus phprus marked this pull request as ready for review November 18, 2022 16:50
@phprus phprus requested a review from vitaut November 18, 2022 16:51
@phprus phprus marked this pull request as draft November 23, 2022 16:20
@phprus phprus marked this pull request as ready for review November 23, 2022 16:44
@phprus
Copy link
Contributor Author

phprus commented Nov 23, 2022

Rebased onto master


constexpr auto leading_shift = ((num_xdigits - 1) * 4);
const auto leading_mask = carrier_uint(0xF) << leading_shift;
const auto leading_v =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "v" stand for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"value".

But, probably, it would be more correct name: "leading_[hex]digit" or "most_significant_[hex]digit".
Now I think leading_* are not good names.

Make a PR with renaming? If yes, which option should I choose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A PR sounds good. I think leading_hexdigit or leading_xdigit (for consistency with num_xdigits) is fine. most_significant_* might be more precise but longer and I think leading is clear enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: PR #3203

@vitaut vitaut merged commit 3136473 into fmtlib:master Nov 24, 2022
@vitaut
Copy link
Contributor

vitaut commented Nov 24, 2022

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants