Address feedback from PR #101401

This commit is contained in:
Sage Mitchell
2022-09-04 08:07:00 -07:00
parent 4a3e169da7
commit 2b328ea5ee
3 changed files with 20 additions and 12 deletions

View File

@@ -16,12 +16,16 @@ const fn bitset_search<
let bucket_idx = (needle / 64) as usize;
let chunk_map_idx = bucket_idx / CHUNK_SIZE;
let chunk_piece = bucket_idx % CHUNK_SIZE;
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
// feature stabilizes.
let chunk_idx = if chunk_map_idx < chunk_idx_map.len() {
chunk_idx_map[chunk_map_idx]
} else {
return false;
};
let idx = bitset_chunk_idx[chunk_idx as usize][chunk_piece] as usize;
// FIXME: const-hack: Revert to `slice::get` after `const_slice_index`
// feature stabilizes.
let word = if idx < bitset_canonical.len() {
bitset_canonical[idx]
} else {

View File

@@ -76,7 +76,7 @@ impl RawEmitter {
writeln!(
&mut self.file,
"const BITSET_CANONICAL: [u64; {}] = [{}];",
"const BITSET_CANONICAL: &'static [u64; {}] = &[{}];",
canonicalized.canonical_words.len(),
fmt_list(canonicalized.canonical_words.iter().map(|v| Bits(*v))),
)
@@ -84,7 +84,7 @@ impl RawEmitter {
self.bytes_used += 8 * canonicalized.canonical_words.len();
writeln!(
&mut self.file,
"const BITSET_MAPPING: [(u8, u8); {}] = [{}];",
"const BITSET_MAPPING: &'static [(u8, u8); {}] = &[{}];",
canonicalized.canonicalized_words.len(),
fmt_list(&canonicalized.canonicalized_words),
)
@@ -135,7 +135,7 @@ impl RawEmitter {
writeln!(
&mut self.file,
"const BITSET_CHUNKS_MAP: [u8; {}] = [{}];",
"const BITSET_CHUNKS_MAP: &'static [u8; {}] = &[{}];",
chunk_indices.len(),
fmt_list(&chunk_indices),
)
@@ -143,7 +143,7 @@ impl RawEmitter {
self.bytes_used += chunk_indices.len();
writeln!(
&mut self.file,
"const BITSET_INDEX_CHUNKS: [[u8; {}]; {}] = [{}];",
"const BITSET_INDEX_CHUNKS: &'static [[u8; {}]; {}] = &[{}];",
chunk_length,
chunks.len(),
fmt_list(chunks.iter()),