Fastest Way of Accessing Entries in an AA

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 8 08:10:54 PST 2015


On Thu, 08 Jan 2015 15:59:10 +0000
"Nordlöw" via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
wrote:

> On Thursday, 8 January 2015 at 15:49:46 UTC, Dragos Carp wrote:
> > On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote:
> >> Is
> >>
> >>    key in aa ? aa[key] : ValueType.init;
> >>
> >> the most efficient way to maybe return a value from an 
> >> associative array aa?
> >
> > aa.get(key, ValueType.init)
> 
> That was too easy ;)
> 
> It would be nice if the compiler could detect usage of aa.get() 
> automatically and issue either a diagnostics or transform it in 
> an optimization pass.
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. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150108/eb228193/attachment-0001.sig>


More information about the Digitalmars-d-learn mailing list