[Issue 2504] New: Reserve for associative arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 10 06:57:12 PST 2008


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

           Summary: Reserve for associative arrays
           Product: D
           Version: 2.021
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: dsimcha at yahoo.com


It appears that adding an element to an associative array always triggers a
memory allocation.  Especially in multithreaded code, this is inefficient.  It
would be nice if associative arrays had a .reserve(size_t n) property, which
reserved enough space for n objects, and stored the capacity internally.  The
idea is that, until the reserve buffer is exhausted, no interaction of any kind
with the GC would be needed to add an element to the AA.


-- 



More information about the Digitalmars-d-bugs mailing list