I'm not sure 0'ing these bits is right to begin with: a bitset can reference external data, which may have padding bits that are non-zero. bitsets can share their their bits, so the padding bits may be non-zero. Long story short, we can't make the assumptions that the padding bits are 0. Setting them to 0 is a useless operation, since we can't exploit this anyways.

On the contrary, setting them to 0 may corrupt the memory structure it is pointing into, or other bitsets that are sharing the array.

My conclusion is that this code is entirely useless *and* wrong, and should just be entirely omitted.

If anything, it is the *non* padding bits that should be changed to 0, if the bitset grows, but without changing dimensions (growing and changing dimensions *should* result in 0'd memory anyways). As a matter of fact, the unittest doesn't check this, since the arrays will relocate on extension. *This* test should be more relevant (I think):
```D
        BitArray a;
        a.length = 16;
        foreach (ref e; a)
            e = true;
        BitArray b = a;
        a.length = 8; //padding bits should be left unchanged
        foreach (i,e; b)
            assert(e == true); //this should pass (IMO)
        a.length = 16; //new bits should be set to 0
        foreach (i,e; a)
            assert(e == (i < 8)); //*This* will fail, but it should pass.
```

EDIT: Well, your new code is better than the old code, but I think no code would be even better.