Change representation of dynamic arrays?

Graham St Jack grahams at acres.com.au
Sun Oct 21 17:25:12 PDT 2007


If we are considering changing the internal representation of dynamic 
arrays, maybe we should also consider adding a pointer to "end of 
allocation", making it three pointers in total.

The extra pointer could be used by the concatenation operators to 
dramatically reduce the number of reallocs that occur when doing ~= 
appends to a dynamic array - by only realloc-ing when capacity runs out, 
and allocating more capacity than immediately needed.

I currently have to use a more heavy-weight container class (like a 
Vector) if I don't want to pay the performance cost of repeated 
reallocs, and it seems to me that cranking up the "out of the box" 
performance of dynamic arrays when concatenating would be good.



More information about the Digitalmars-d mailing list