[Issue 10828] New: datetime toString functions should accept sink
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 15 12:59:03 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10828
Summary: datetime toString functions should accept sink
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: monarchdodra at gmail.com
--- Comment #0 from monarchdodra at gmail.com 2013-08-15 12:59:01 PDT ---
Basically, all datetime functions' "toString" signature are:
"string toString();"
There should be an overload which accepts a sink (eg:)
"const void toString(scope void delegate(const(char)[]) sink);"
Without this, code such as:
writeln(currentTime)
Will needlessly allocate a string.
This is an issue for this user:
http://forum.dlang.org/thread/ofelyiymbyywethtfjxh@forum.dlang.org#post-ypgppdursxtwljhkjoed:40forum.dlang.org
Who wants to log the time at which destruction happens. This leads to a:
core.exception.InvalidMemoryOperationError
Due to an allocation during a collect.
Implementation should be "trivial"*, since the implementation of "toString" is
basically "return format("%%%%", args)".
So this can "easily" be changed to:
"formattedWrite(sink, "%%%%", args)"
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list