www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10828] New: datetime toString functions should accept sink


           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 puremagic.com
        ReportedBy: monarchdodra gmail.com

--- Comment #0 from monarchdodra 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:
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:
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: -------
Aug 15 2013