mirror of
https://github.com/dlang/phobos.git
synced 2025-05-04 17:11:26 +03:00
Clean up after making formating floating point numbers @nogc.
This commit is contained in:
parent
afc2df6ef2
commit
3206e52aae
4 changed files with 976 additions and 1023 deletions
8
changelog/formatting_floats_nogc.dd
Normal file
8
changelog/formatting_floats_nogc.dd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Floating point numbers don't allocate with the GC anymore.
|
||||||
|
|
||||||
|
The implementation of formatting floating point numbers has been
|
||||||
|
reworked. We made sure that working examples never allocate with the
|
||||||
|
GC, however, we are still using exceptions which are GC managed.
|
||||||
|
Therefore, code that uses formatting correctly will never allocate,
|
||||||
|
but in the case of exceptions, the GC will be used to allocate the
|
||||||
|
exception. We are working on DIP 1008 to solve this issue.
|
File diff suppressed because it is too large
Load diff
|
@ -506,9 +506,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.spec = spec2;
|
fs.spec = spec2;
|
||||||
buf = printFloat(buf2[], w, val, fs, mode);
|
printFloat(w, val, fs, mode);
|
||||||
len = buf.length;
|
|
||||||
if (len == 0) return;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -561,7 +559,6 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
|
||||||
|
|
||||||
len = min(n, buf2.length-1);
|
len = min(n, buf2.length-1);
|
||||||
buf = buf2;
|
buf = buf2;
|
||||||
}
|
|
||||||
|
|
||||||
if (fs.flSeparator && !inf && !nan)
|
if (fs.flSeparator && !inf && !nan)
|
||||||
{
|
{
|
||||||
|
@ -644,6 +641,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
|
||||||
put(w, buf[0 .. len]);
|
put(w, buf[0 .. len]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
|
|
|
@ -1511,8 +1511,6 @@ Note:
|
||||||
|
|
||||||
$(UL
|
$(UL
|
||||||
$(LI An exception is thrown.)
|
$(LI An exception is thrown.)
|
||||||
$(LI A floating point number of type `real` is formatted.)
|
|
||||||
$(LI The representation of a floating point number exceeds 500 characters.)
|
|
||||||
$(LI A custom `toString` function of a compound type allocates.))
|
$(LI A custom `toString` function of a compound type allocates.))
|
||||||
*/
|
*/
|
||||||
char[] sformat(Char, Args...)(return scope char[] buf, scope const(Char)[] fmt, Args args)
|
char[] sformat(Char, Args...)(return scope char[] buf, scope const(Char)[] fmt, Args args)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue