diff options
author | David Robillard <d@drobilla.net> | 2023-05-03 22:12:28 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-05-03 22:12:28 -0400 |
commit | 8afe1814483ec10f1f425a60d1fc80fe6e3cd8f1 (patch) | |
tree | 521a2f186845188d1e9c6970e41b5b65a255feff | |
parent | aa6d24924b0449424bd58f667657f4087a573f9c (diff) | |
download | chilbert-8afe1814483ec10f1f425a60d1fc80fe6e3cd8f1.tar.gz chilbert-8afe1814483ec10f1f425a60d1fc80fe6e3cd8f1.tar.bz2 chilbert-8afe1814483ec10f1f425a60d1fc80fe6e3cd8f1.zip |
Avoid boolean arithmetic
-rw-r--r-- | include/chilbert/detail/gray_code_rank.hpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/chilbert/detail/gray_code_rank.hpp b/include/chilbert/detail/gray_code_rank.hpp index b049540..f87fa4b 100644 --- a/include/chilbert/detail/gray_code_rank.hpp +++ b/include/chilbert/detail/gray_code_rank.hpp @@ -88,6 +88,8 @@ gray_code_rank_inv(const I& mask, I& g, I& gi) { + using Rack = typename I::Rack; + assert(mask.size() == n); assert(ptrn.size() == n); assert(r.size() == n); @@ -100,9 +102,9 @@ gray_code_rank_inv(const I& mask, auto m = mask.mask(n - 1); auto ri = r.begin(b - 1); - typename I::Rack gi0 = 0; - typename I::Rack gi1 = 0; - typename I::Rack g0 = 0; + Rack gi0{}; + Rack gi1{}; + Rack g0{}; for (size_t i = 0; i < n; ++i) { if (mask.test(m)) { // Unconstrained bit @@ -117,7 +119,7 @@ gray_code_rank_inv(const I& mask, } --ri; } else { // Constrained bit - g0 = (ptrn.test(m) > 0); + g0 = Rack{ptrn.test(m)}; gi1 = gi0; gi0 = g0 ^ gi1; if (gi0) { |