Fastest Way of Accessing Entries in an AA
Foo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 8 16:20:07 PST 2015
On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote:
> On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via
> Digitalmars-d-learn wrote:
>> how can it? compiler doesn't know what the code is supposed to
>> do. if
>> compilers will know such things someday, we can stop writing
>> programs
>> altogether, as compilers will be able to write any program for
>> us. ;-)
>
> Correction:
>
> I thought it would be nice if the compiler explained to me that
>
> key in aa ? aa[key]
>
> is a sub-optimal performance-wise.
You know, that you kan reuse the result of the in operator by AAs?
example:
auto ptr = key in aa;
ptr ? *ptr : ValueType.init
More information about the Digitalmars-d-learn
mailing list