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

Simplifying format_decimal() #2498

Merged
merged 2 commits into from
Sep 12, 2021
Merged

Simplifying format_decimal() #2498

merged 2 commits into from
Sep 12, 2021

Conversation

Roman-Koshelev
Copy link
Contributor

No description provided.

include/fmt/format.h Outdated Show resolved Hide resolved
Comment on lines 1078 to 1079
char dc0 = *src++;
char dc1 = *src;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to introduce these variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the same, this gives the compiler the ability to generate more efficient code. (Although he may not use it)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you give an example on godbolt illustrating this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://godbolt.org/z/YKvoshP8K This is not enough? We untie the compiler's hands without losing anything.

Copy link
Contributor

@vitaut vitaut Sep 12, 2021

Choose a reason for hiding this comment

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

Interesting. Could you add a short comment clarifying that this opens optimization opportunities because otherwise it might be tempting to remove these seemingly redundant variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

logical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

@vitaut vitaut merged commit e47e99b into fmtlib:master Sep 12, 2021
@vitaut
Copy link
Contributor

vitaut commented Sep 12, 2021

Thank you!

PoetaKodu pushed a commit to pacc-repo/fmt that referenced this pull request Nov 11, 2021
* Add copy2() constexpr

* Removed redundant format_decimal implementation for constexpr context
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