-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
std.format: Make formatting 0.0 100% @nogc. #8000
Conversation
|
Thanks for your pull request and interest in making D better, @berni44! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#8000" |
| @@ -925,6 +925,12 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) | |||
| assert(format("%a", r) == "0x1p-20"); | |||
| } | |||
|
|
|||
| // https://issues.dlang.org/show_bug.cgi?id=21836 | |||
| @safe pure unittest | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nogc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not @nogc since some code paths in the called function allocate, even though those paths are not taken when called with the argument in the unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have an assertGCNotCalled test helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a @nogc-test in std.format.internal.floats. I think, it can be made @nogc once the three followups on this are merged and formatting floats is completely @nogc, not only zeros, nans and infs.
|
|
||
| return result; | ||
| } | ||
|
|
||
| // check no allocations | ||
| @system unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is this test.
Followup on #7971; see there for the roadmap.
The calls to
printFloat0are replaced by a calls towriteAlignedwhich does the same more general and without allocating.writeAlignedneeded another parameter: fractional digits are yet another stretchable element due to trailing zeros. The interpretation ofprecisionfor floating point values differs from the interpretation of it for integral values. Therefore I added anenum PrecisionTypeto distinguish the various meanings ofprecision. Eventually it will replace the boolean parameterinteger_precision- for the time being I added an additional wrapper.