removing an item from a dynamic array
bearophile
bearophileHUGS at lycos.com
Wed Oct 26 05:00:59 PDT 2011
Steven Schveighoffer:
> Note that there *is* overhead, even if it's not significant. I highly
> recommend never to use [] and use null instead.
In Bugzilla I did ask for the opposite (but not on a performance basis) :-)
null is less specific than [] because a null is also used for pointers and references, while [] is only for empty associative arrays and empty dynamic arrays. An empty dynamic array is a 2-words struct, so representing its literal with just a null (that is a single word) looks misleading and doesn't help D novices remember what a dynamic array is. I have even suggested to use [:] as empty associative array literal in D.
Regarding the difference in [] and null performance, I think adding a small optimization to the front-end is a better solution to this little problem.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list