[Issue 1556] New: Inefficient array concatenation (especially for 3+ arrays)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 8 01:51:20 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1556
Summary: Inefficient array concatenation (especially for 3+
arrays)
Product: DGCC aka GDC
Version: 0.24
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: glue layer
AssignedTo: dvdfrdmn at users.sf.net
ReportedBy: fvbommel at wxs.nl
GDC (0.24) compiles "a~b~c~d~e~f~g~h" (where all variables are arrays) to
multiple invocations of _d_arraycatnT, a function which can handle any number
of arrays but only seems to get called for two at a time. This causes N-1
function calls (each of which performs an allocation) instead of only one. This
is inefficient and causes extra garbage on the heap.
GDC also generates calls to this multi-array function for a simple 2-array
case, even though gphobos has _d_arraycatT especially for this purpose, without
the overhead of vararg handling.
DMD (both 1.022 and 1.020 on which GDC 0.24 was based) does this right, calling
_d_arraycatT for a 2-array concat and _d_arraycatnT to concatenate 3+ arrays.
Note: I'm tempted to add keyword "wrong-code" to this report, but the code
*does* return the right result (an array filled with the concatenation of the
initial arrays) so I'm not sure if it applies.
--
More information about the D.gnu
mailing list