[Issue 2528] New: Arrays in Phobos shold be pre-allocated.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 20 18:28:00 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2528

           Summary: Arrays in Phobos shold be pre-allocated.
           Product: D
           Version: 2.022
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: dsimcha at yahoo.com


Looking at the sources to Phobos, I see several places, including
std.algorithm.map(), and the array-to-array conversion function of std.conv,
where the ~= operator is used, even though the length of the array returned by
these functions is known at the beginning of the function.  This severely hurts
the performance of these functions, given how slow ~= is.  Furthermore, even if
~= were efficient, reallocating an array instead of preallocating is still too
inefficient when it can be trivially optimized out.


-- 



More information about the Digitalmars-d-bugs mailing list