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

Fix strformat neg zero #7954

Merged
merged 5 commits into from
Jun 5, 2018
Merged

Conversation

skilchen
Copy link
Contributor

@skilchen skilchen commented Jun 4, 2018

only add explicitly requested sign if value != -0.0 (neg zero)
see issue #7923

if value == 0.0:
if 1.0 / value == Inf:
# only add the sign if value != negZero
f = spec.sign & f
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 use insert instead, to modify 'f' in place? It would be nice to reduce the number of temporary string allocations made in this procedure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are other places where we could use insert instead of string concatenation, but i limit the change strictly to the area i want to fix (no + in front of negative zero).

Personally i don't like inplace mutations, therefore I will not produce PR's to change other places in strformat to use inplace mutations.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't matter if you like them or not, they are faster and this is a "standard library" where everybody benefits from faster code.

@Varriount Varriount merged commit 230692a into nim-lang:devel Jun 5, 2018
@skilchen skilchen deleted the fix_strformat_neg_zero branch June 15, 2018 13:28
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.

3 participants