Do you use D's GC?
Steven Schveighoffer
schveiguy at gmail.com
Tue Aug 3 18:34:55 UTC 2021
On 8/3/21 2:21 PM, jfondren wrote:
> On Tuesday, 3 August 2021 at 18:18:48 UTC, Steven Schveighoffer wrote:
>> It's no different for length setting:
>>
>> ```d
>> buffer = new int[100];
>> auto buffer2 = buffer;
>> buffer.length = 50;
>> buffer.length = 51; // must reallocate
>> buffer[$-1] = 10;
>> ```
>
> All of the buffer-stomping "must reallocate" cases are preserved in the
> rewrite that only assigns buffer.length when the new value is larger.
> The cases that were omitted, that were a performance drain, were
> same-length or less-length assignments.
>
There is not a reallocation on shrinking of length. Or am I
misunderstanding your statement?
-Steve
More information about the Digitalmars-d
mailing list