Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Thursday, 29 May 2014 at 12:04:35 UTC, monarch_dodra wrote: On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote: monarch_dodra: Hm. This last point might be an issue. If I process a large input (text in this case) then I might run into trouble with "append" as a class variable. I also had

Re: Cost of .dup vs. instantiation

2014-05-29 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 29 May 2014 at 08:49:10 UTC, Chris wrote: monarch_dodra: Hm. This last point might be an issue. If I process a large input (text in this case) then I might run into trouble with "append" as a class variable. I also had a weird bug, because I didn't clear the memory for overwrite.

Re: Cost of .dup vs. instantiation

2014-05-29 Thread Chris via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 17:33:19 UTC, monarch_dodra wrote: On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote: I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the funct

Re: Cost of .dup vs. instantiation

2014-05-28 Thread TheFlyingFiddle via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote: I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the function must be dup'ed, like so: Appender!(MyType[]) append; publi

Re: Cost of .dup vs. instantiation

2014-05-28 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 14:36:25 UTC, Chris wrote: I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the function must be dup'ed, like so: Appender!(MyType[]) append; publi

Cost of .dup vs. instantiation

2014-05-28 Thread Chris via Digitalmars-d-learn
I use Appender to fill an array. The Appender is a class variable and is not instantiated with each function call to save instantiation. However, the return value or the function must be dup'ed, like so: Appender!(MyType[]) append; public auto doSomething() { scope (exit) { // clear append }