Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 31 August 2019 at 12:07:56 UTC, cc wrote: And what, if anything, can I do to avoid it? import core.stdc.stdio : printf; There are no @nogc versions of the Phobos write* and format functions.

Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread cc via Digitalmars-d-learn
And what, if anything, can I do to avoid it? string[] arr = ["abcd", "efgh", "ijkl"]; char[4096] buf; char[] res; writeln(GC.stats); res = sformat(buf, "%s", arr); assert(res.ptr == buf.ptr); writeln(res); writeln(GC.stats);

Re: Java to D

2019-08-31 Thread Patrick via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 10:33:33 UTC, GreatSam4sure wrote: On Wednesday, 28 August 2019 at 09:35:55 UTC, Jacob Carlborg wrote: On 2019-08-28 10:14, GreatSam4sure wrote: [...] DWT is ported manually from Java. Here's a very short guide [1]. That guide is probably written for D1.

Re: Java to D

2019-08-31 Thread Ernesto Castellotti via Digitalmars-d-learn
On Wednesday, 28 August 2019 at 08:14:25 UTC, GreatSam4sure wrote: Good day everyone. DWT is a library for creating cross-platform GUI applications. It's a port of the SWT Java library from Eclipse. Currently supported platforms are Windows, using Win32 and Linux, using GTK. [...]

Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 31 August 2019 at 21:12:32 UTC, ag0aep6g wrote: I've made a pull request to get rid of those allocations: https://github.com/dlang/phobos/pull/7163 Merged.

Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread ag0aep6g via Digitalmars-d-learn
On 31.08.19 14:07, cc wrote: I'm guessing it's allocating a string first to write the contents of the array and then inserting that string into the buffer I supplied. Is there no way to have it skip this step and just write each element (plus the joining punctuation, etc) directly into the