Optimizing Java using D
Wanderer via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 3 08:40:32 PDT 2014
On Thursday, 3 July 2014 at 11:30:57 UTC, Alix Pexton wrote:
> Saying that one is always more significant than the other is
> far too much of an oversimplification.
I just thought, with the presence of structs in D, things are not
that simple. Structs don't use references and their contents is
located "right in place" if I understand this correctly.
In other words, if you have array of structs, each struct of 100K
size, and array's size is 10,000 elements, calling sort on it
would require shuffling 1 gigabyte of memory in the worst case,
stopping the entire application. (Sorting the same array in Java
would require shuffling only 40K of references and would finish
instantly, because only reference complex types are allowed
there.)
All I can say - yes, amount of swaps can be important in this
case of structs, but it's terribly inefficient anyway and should
be avoided IMHO.
More information about the Digitalmars-d
mailing list