From dd34f7fd504fbbd57e7802da4e76447c4911ab09 Mon Sep 17 00:00:00 2001 From: Nikita Sivukhin Date: Tue, 14 Oct 2025 22:19:01 +0400 Subject: [PATCH] wip --- core/lib.rs | 1 + core/storage/btree.rs | 12 +++++++----- core/vdbe/execute.rs | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/lib.rs b/core/lib.rs index 2a0a558cf..9b93d64ad 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -15,6 +15,7 @@ mod json; pub mod mvcc; mod parameters; mod pragma; +pub mod primitives; mod pseudo; mod schema; #[cfg(feature = "series")] diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 909bb5de3..5a37ba568 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -41,7 +41,7 @@ use super::{ use parking_lot::RwLock; use std::{ any::Any, - cell::{Cell, Ref, RefCell}, + cell::Cell, cmp::{Ordering, Reverse}, collections::{BinaryHeap, HashMap}, fmt::Debug, @@ -50,6 +50,8 @@ use std::{ sync::Arc, }; +use crate::primitives::{Ref, RefCell, RefMut}; + /// The B-Tree page header is 12 bytes for interior pages and 8 bytes for leaf pages. /// /// +--------+-----------------+-----------------+-----------------+--------+----- ..... ----+ @@ -552,7 +554,7 @@ pub trait CursorTrait: Any { // --- start: BTreeCursor specific functions ---- fn invalidate_record(&mut self); fn has_rowid(&self) -> bool; - fn record_cursor_mut(&self) -> std::cell::RefMut<'_, RecordCursor>; + fn record_cursor_mut(&self) -> RefMut<'_, RecordCursor>; fn get_pager(&self) -> Arc; fn get_skip_advance(&self) -> bool; @@ -5422,7 +5424,7 @@ impl BTreeCursor { Ok(IOResult::Done(())) } - fn get_immutable_record_or_create(&self) -> std::cell::RefMut<'_, Option> { + fn get_immutable_record_or_create(&self) -> RefMut<'_, Option> { let mut reusable_immutable_record = self.reusable_immutable_record.borrow_mut(); if reusable_immutable_record.is_none() { let page_size = self.pager.get_page_size_unchecked().get(); @@ -5432,7 +5434,7 @@ impl BTreeCursor { reusable_immutable_record } - fn get_immutable_record(&self) -> std::cell::RefMut<'_, Option> { + fn get_immutable_record(&self) -> RefMut<'_, Option> { self.reusable_immutable_record.borrow_mut() } @@ -6390,7 +6392,7 @@ impl CursorTrait for BTreeCursor { .invalidate(); self.record_cursor.borrow_mut().invalidate(); } - fn record_cursor_mut(&self) -> std::cell::RefMut<'_, RecordCursor> { + fn record_cursor_mut(&self) -> RefMut<'_, RecordCursor> { self.record_cursor.borrow_mut() } diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index dcfa26046..e74f64a1c 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -110,7 +110,7 @@ macro_rules! load_insn { }; #[cfg(not(debug_assertions))] let Insn::$variant { $($field $(: $binding)?),*} = $insn else { - // this will optimize away the branch + // this will optimize away the branch unsafe { std::hint::unreachable_unchecked() }; }; };