[Issue 20566] New: std.sformat should avoid allocating memory when printing floating point values
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 8 07:32:00 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20566
Issue ID: 20566
Summary: std.sformat should avoid allocating memory when
printing floating point values
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: r.sagitario at gmx.de
from
https://digitalmars.com/d/archives/digitalmars/D/learn/format_with_floating_points_GC_allocating_in_DMD_2.090_113888.html
:
import std.format;
import core.memory;
import std.stdio;
import std.format;
void main()
{
char[4096] buf;
writeln(GC.stats.usedSize);
foreach (i; 0 .. 10) {
sformat(buf[], "%a", 1.234f);
writeln(GC.stats.usedSize);
}
}
shows that an invocation of sformat allocates, even though a large buffer is
passed in. This didn't happen in 2.089, but in 2.090 and all other versions
before 2.089.
--
More information about the Digitalmars-d-bugs
mailing list