From cba84b7ce94fc3f9070ace679a12585c564a51bb Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 5 Jun 2025 09:36:29 +0300 Subject: [PATCH] Remove premature cast to usize (cell_idx can be negative) --- core/storage/btree.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index d4add2388..71c1dc541 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -738,13 +738,7 @@ impl BTreeCursor { let contents = page.get().contents.as_ref().unwrap(); let cell_count = contents.cell_count(); - let cell_idx = self.stack.current_cell_index() as usize; - // dbg!( - // page.get().id, - // self.stack.current_cell_index(), - // self.going_upwards, - // page.get_contents().cell_count() - // ); + let cell_idx = self.stack.current_cell_index(); // If we are at the end of the page and we haven't just come back from the right child, // we now need to move to the rightmost child. @@ -756,7 +750,7 @@ impl BTreeCursor { continue; } } - if cell_idx >= cell_count { + if cell_idx >= cell_count as i32 { self.stack.set_cell_index(cell_count as i32 - 1); } else { let is_index = page.is_index();