Static Initialization of AAs - when?

Steven Schveighoffer schveiguy at gmail.com
Mon May 30 20:49:34 UTC 2022


On 5/30/22 4:39 PM, Sergey wrote:
> On Sunday, 29 May 2022 at 15:34:09 UTC, Steven Schveighoffer wrote:
>> On 5/28/22 8:36 PM, arandomonlooker wrote:
>> But you can just use it as a drop-in replacement for builtin AAs. It 
>> actually is binary compatible, so you can have both a normal builtin 
>> AA reference to it, and a `Hash` reference, and both will work.
>>
> 
> Hi Steven!
> What about speed and performance?
> Did you compare it with built-in AA?

No, but if anything, I'd expect it to be a tad bit faster, since it 
doesn't use TypeInfo for many things such as hash calculation, and it 
can be inlined.

It might be slower in CTFE, since the interpreter is running the actual 
code instead of the builtin CTFE AA. However, you can use the builtin 
CTFE AA, and then just return a `Hash` as a result.

Note that all the factors and the algorithms are identical to how 
druntime does it (I copied that code verbatim, which is why the 
copyright is from there). It has to be, because its aim is to be binary 
compatible.

-Steve


More information about the Digitalmars-d mailing list