Fix growable bitset (#1032)

This commit is contained in:
Christoffer Lerno
2023-10-06 01:27:32 +02:00
committed by GitHub
parent dad21bfc6f
commit a1bce81ed0
2 changed files with 6 additions and 2 deletions

View File

@@ -106,10 +106,15 @@ fn void GrowableBitSet.set(&self, usz i)
{
usz q = i / BITS;
usz r = i % BITS;
if (q >= self.data.len())
usz current_len = self.data.len();
if (q >= current_len)
{
usz n = q + 1;
self.data.reserve(n);
if (n - 1 >= current_len)
{
self.data.entries[current_len .. (n - 1)] = 0;
}
self.data.size = n;
}
self.data.set(q, self.data[q] | (1 << r));