Enhanced array appending

Steven Schveighoffer schveiguy at yahoo.com
Mon Dec 21 12:26:47 PST 2009


All,

I created a new patched druntime that prevents array stomping and at the  
same time increases append performance for thread-local array appending.

The patch is attached to bugzilla entry 3637. (  
http://d.puremagic.com/issues/show_bug.cgi?id=3637 )

For those of you unfamiliar with array stomping, here is code that  
demonstrates the problem:

int[] a = [1,2,3].dup;
int[] b = a[0..1];
b ~= 4;
assert(b == [1,4]);
assert(a == [1,2,3]); // fails with old code, passes with mine.

Note that my code still does not help with the problem of having a shared  
view of data when appending, as outlined in Bartosz's NG thread "D array  
expansion and non-deterministic re-allocation."  I don't think this  
problem can be solved without sacrificing performance of array appending.

For those of you unfamiliar with D's poor array append performance, please  
see  
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=103563

Please give it a try and see if you can find any issues with it.  I'm  
sorry that I don't have a binary distribution channel for this.  Maybe  
someone can build some binaries for others to download.

-Steve



More information about the Digitalmars-d mailing list