Removing elements from dynamic arrays?

Chris Nicholson-Sauls ibisbasenji at
Fri Nov 3 19:02:39 PST 2006

Sean Kelly wrote:
> Chris Nicholson-Sauls wrote:
>> Anyhow, clearly your .drop() is running very fast!  I actually 
>> expected the opposite, and am surprised/impressed.
>> Maybe you should release it into Cashew?  ;)  And maybe I should put 
>> more into benchmarking the entire Cashew array module.  There might be 
>> a few more placed it could be sped up.
> I'd be interested in seeing a test using C's memmove as well.  Though 
> I'm not surprised drop beats the slice version, since that will allocate 
> a new array for the data.
> Sean

Well, I just benchmarked the memmove() based approach, and it is indeed notably faster 
still.  Here's a typical sample from the results:

<Benchmark traverse vs memmove> Baseline 3.130000
<Benchmark traverse vs memmove> Time 1.760000 & 1.778409 versus baseline

(Where the baseline was the current .drop() and the contender was a .drop() using 
memmove().)  So, indeed, I am migrating Cashew to use memmove().  I may also modify 
.dropIf() to use it as well.

-- Chris Nicholson-Sauls

More information about the Digitalmars-d-learn mailing list