Avoid relying on const parameters to function

LLVM seems to at least sometimes optimize better when the length comes directly
from the `len()` of the array vs. an equivalent integer.

Also, this allows easier copy/pasting of the function into compiler explorer for
experimentation.
This commit is contained in:
Mark Rousskov
2020-03-21 18:01:50 -04:00
parent a7ec6f8fe0
commit af243d4d91
2 changed files with 8 additions and 8 deletions

View File

@@ -25,11 +25,11 @@ fn range_search<
} else {
return false;
};
let idx = bitset_chunk_idx[(chunk_idx as usize)][chunk_piece] as usize;
let word = if idx < CANONICAL {
bitset_canonical[idx]
let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize;
let word = if let Some(word) = bitset_canonical.get(idx) {
*word
} else {
let (real_idx, mapping) = bitset_canonicalized[idx - CANONICAL];
let (real_idx, mapping) = bitset_canonicalized[idx - bitset_canonical.len()];
let mut word = bitset_canonical[real_idx as usize];
let should_invert = mapping & (1 << 6) != 0;
if should_invert {