I don't like slices in D
Adam D. Ruppe
destructionator at gmail.com
Thu Oct 17 11:59:46 PDT 2013
On Thursday, 17 October 2013 at 18:41:53 UTC, Vitali wrote:
> arr = arr[0..index] ~ arr[index+1..$];
This line is where the reallocation happens. a ~ b on built in
arrays and slices, ALWAYS allocates to ensure it doesn't stomp
over some other in-use memory.
~= can extend if there's capacity, but ~ always makes a new array
without modifying the input. Ali linked to the array article that
explains the implementation in more detail.
The remove function should copy the data itself instead of using
the ~ operator if you want it to operate in place.
More information about the Digitalmars-d
mailing list