dynamic array .length vs .reserve - what's the difference?
wjoe
invalid at example.com
Mon Aug 3 12:48:40 UTC 2020
On Saturday, 1 August 2020 at 16:04:01 UTC, Steven Schveighoffer
wrote:
> On 7/31/20 12:32 PM, wjoe wrote:
>> On Friday, 31 July 2020 at 04:28:57 UTC, Ali Çehreli wrote:
>>> Another option, which is curiously said to be more performant
>>> in memory allocation than native arrays, is
>>> std.array.Appender. I've used function-local static Appenders
>>> to cut down on memory allocation. Here is an uncompiled
>>> pseudo code:
>>>
>>> [...]
>>
>> This looks like an even better way to do it.
>>
>> Thanks, Ali :)
>
> Just FYI, the reason this is faster is because there is no need
> to go through the opaque calls into druntime to figure out if
> appending-in-place is possible. The reserved length is stored
> directly in the struct.
>
> -Steve
That's good to know, thanks :)
By the looks of it, Appender is half duplicating the runtime :)
More information about the Digitalmars-d-learn
mailing list