Skip to content

Commit 455bc95

Browse files
author
Ahmet Inan
committed
pack used flags
1 parent c17ca2f commit 455bc95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cauchy_prime_field_erasure_coding.hh

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct CauchyPrimeFieldErasureCoding
1313
{
1414
static_assert(MAX_LEN < int(PF::P-1), "Block length must be smaller than largest field value");
1515
PF temp[MAX_LEN];
16-
bool used[PF::P];
16+
uint8_t used[(PF::P+7)/8];
1717
PF row_num, row_den;
1818
// $a_{ij} = \frac{1}{x_i + y_j}$
1919
PF cauchy_matrix(int i, int j)
@@ -103,12 +103,12 @@ struct CauchyPrimeFieldErasureCoding
103103
}
104104
int find_unused(int block_len)
105105
{
106-
for (int i = 0; i < int(PF::P); ++i)
107-
used[i] = false;
106+
for (int i = 0; i < int(PF::P+7)/8; ++i)
107+
used[i] = 0;
108108
for (int i = 0; i < block_len; ++i)
109-
used[temp[i]()] = true;
109+
used[temp[i]()/8] |= 1 << temp[i]()%8;
110110
int s = 0;
111-
while (used[s])
111+
while (used[s/8] & 1 << s%8)
112112
++s;
113113
return s;
114114
}

0 commit comments

Comments
 (0)