From 455bc95a24b17ed2f4c174e890de2a586b186e12 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Thu, 28 Mar 2024 08:39:26 +0100 Subject: [PATCH] pack used flags --- cauchy_prime_field_erasure_coding.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cauchy_prime_field_erasure_coding.hh b/cauchy_prime_field_erasure_coding.hh index 5465b16..e481102 100644 --- a/cauchy_prime_field_erasure_coding.hh +++ b/cauchy_prime_field_erasure_coding.hh @@ -13,7 +13,7 @@ struct CauchyPrimeFieldErasureCoding { static_assert(MAX_LEN < int(PF::P-1), "Block length must be smaller than largest field value"); PF temp[MAX_LEN]; - bool used[PF::P]; + uint8_t used[(PF::P+7)/8]; PF row_num, row_den; // $a_{ij} = \frac{1}{x_i + y_j}$ PF cauchy_matrix(int i, int j) @@ -103,12 +103,12 @@ struct CauchyPrimeFieldErasureCoding } int find_unused(int block_len) { - for (int i = 0; i < int(PF::P); ++i) - used[i] = false; + for (int i = 0; i < int(PF::P+7)/8; ++i) + used[i] = 0; for (int i = 0; i < block_len; ++i) - used[temp[i]()] = true; + used[temp[i]()/8] |= 1 << temp[i]()%8; int s = 0; - while (used[s]) + while (used[s/8] & 1 << s%8) ++s; return s; }