BitArray implementation issue

safety0ff via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 22 19:33:38 PDT 2014


On Wednesday, 23 July 2014 at 00:59:38 UTC, H. S. Teoh via 
Digitalmars-d wrote:
>
> You might want to consider implementing a way of tracking how 
> many bits
> in the final word are valid. That way, you can correctly trigger
> reallocation if the user tries to write to a bit beyond the 
> current end
> of the array (instead of stomping over other BitArray's data), 
> and you
> don't have to clear any bits except newly-allocated words. 
> Assuming we
> want to keep dynamic-array-like behaviour for BitArray, that 
> is. I think
> it's a good idea.

In brief, you're suggesting to always realloc on extension, no 
matter if it's a sub-word extension.
This solves the stomping issue nicely, but it would cause a lot 
of GC churn in a concatenation loop.


More information about the Digitalmars-d mailing list