From 40fcdb8add65d40a994e7514af199c35ef207c42 Mon Sep 17 00:00:00 2001 From: Tpt Date: Mon, 30 Jan 2023 18:08:15 +0100 Subject: [PATCH] IndexTable::find_entry: add assertion bound checking Allows to avoid a bound check on each `read_entry` call --- src/index.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.rs b/src/index.rs index f598209f..16e827d4 100644 --- a/src/index.rs +++ b/src/index.rs @@ -233,6 +233,7 @@ impl IndexTable { #[inline(never)] fn find_entry(&self, key_prefix: u64, sub_index: usize, chunk: &[u8]) -> (Entry, usize) { + assert!(chunk.len() >= CHUNK_ENTRIES * 8); let partial_key = Entry::extract_key(key_prefix, self.id.index_bits()); for i in sub_index..CHUNK_ENTRIES { let entry = Self::read_entry(chunk, i);