why use string for this example of appender?
ludo
fakeaddress at gmail.com
Thu Apr 1 13:17:44 UTC 2021
Thank Steve,
I open a new thread with some corrections, better title, etc.
On Wednesday, 31 March 2021 at 22:05:12 UTC, Steven Schveighoffer
wrote:
> On 3/31/21 5:32 PM, ludo wrote:
>> [...]
>
> ArrayBuilder should be similar in performance to Appender. I
> think part of the issue with appender could be the ref counted
> design. Only 1000 elements is going to show heavily the
> setup/teardown time of allocation of the implementation struct.
> But that is a guess. You may want to up the repetition count to
> 100 or 1000.
>
> Note your code for appending with length is not doing what you
> think:
>
> void concat_withLength()
> {
> int[] array;
> array.length = 1000;
> for (int j=0; j<1000; j++)
> array ~= j;
> }
>
> This allocates 1000 elements, and then append 1000 *more*
> elements.
>
> I think you meant in the loop:
>
> array[j] = j;
>
> This should be the fastest one.
>
> -Steve
More information about the Digitalmars-d-learn
mailing list