Re: BitArray implementation issue

2014-07-22 Thread safety0ff via Digitalmars-d
On Wednesday, 23 July 2014 at 00:59:38 UTC, H. S. Teoh via Digitalmars-d wrote: I think it's best to keep a bit count of the number of valid bits at the end of the array, in addition to the number of words in the underlying array. You might also want to consider keeping a bit count of the num

Re: BitArray implementation issue

2014-07-22 Thread safety0ff via Digitalmars-d
On Wednesday, 23 July 2014 at 02:33:39 UTC, safety0ff wrote: 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 Actually, you'd need to allocate and copy on each extension, not realloc, because realloc wo

Re: BitArray implementation issue

2014-07-22 Thread safety0ff via Digitalmars-d
On Wednesday, 23 July 2014 at 02:33:39 UTC, safety0ff wrote: but it would cause a lot of GC churn in a concatenation loop. Nevermind this. :o)

Re: BitArray implementation issue

2014-07-22 Thread safety0ff via Digitalmars-d
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 t

Re: BitArray implementation issue

2014-07-22 Thread H. S. Teoh via Digitalmars-d
On Tue, Jul 22, 2014 at 05:57:48PM -0700, 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 > e

Re: BitArray implementation issue

2014-07-22 Thread H. S. Teoh via Digitalmars-d
On Tue, Jul 22, 2014 at 09:16:35PM +, safety0ff via Digitalmars-d wrote: > Currently the implementation of BitArray's length setter is badly broken. > Its implementation contains this code segment: > > if (newdim != olddim) { > auto b = ptr[0 .. olddim]; > b.length = newdim

BitArray implementation issue

2014-07-22 Thread safety0ff via Digitalmars-d
Currently the implementation of BitArray's length setter is badly broken. Its implementation contains this code segment: if (newdim != olddim) { auto b = ptr[0 .. olddim]; b.length = newdim;// realloc ptr = b.ptr; if (newdim & (bitsPerSizeT-1)) // Set any