[Issue 10009] foreach_reverse and AA.byKey/byValue

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 25 19:17:55 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=10009

--- Comment #20 from yebblies <yebblies at gmail.com> ---
(In reply to hsteoh from comment #18)
> 
> I think retaining insertion order is a needless overhead; if you needed such
> a thing, it should be implemented in the library instead.

Sure, but sometimes it's really handy.  I've mostly wanted it when writing
tests that accidentally relied on AA iteration order, which is perfectly stable
unless you run the tests on different architectures.  It's not a big deal but
it's a nice user-friendliness thing.  Anyone looking for high performance in
the built-in AAs is on the wrong track.

(In reply to Ketmar Dark from comment #19)
> but you can implement your own AAs that does exactly this. built-in AAs
> aren't *that* special, just some sugar here and there, plus some D code in
> druntime.

Sure, but I tend to think of the builtin AAs as convenient but not necessarily
high performance. 

> actually, retaining insertion order will not be *that* slow, but you'll need
> two more pointers for each inserted element. this will even make some use
> cases faster (aa.byKey.first, for example, which is awfully slow now).
> 
> yet i'm not sure that everyone are ready to pay 8/64 bytes per AA element
> for this feature.

Maybe not.

--


More information about the Digitalmars-d-bugs mailing list