diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 77de6e9be..e61dc5888 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -203,19 +203,6 @@ fn get_cursor_as_index_mut<'long, 'short>( cursor } -fn get_cursor_as_pseudo_mut<'long, 'short>( - cursors: &'short mut RefMut<'long, Vec>>, - cursor_id: CursorID, -) -> &'short mut PseudoCursor { - let cursor = cursors - .get_mut(cursor_id) - .expect("cursor id out of bounds") - .as_mut() - .expect("cursor not allocated") - .as_pseudo_mut(); - cursor -} - struct Bitfield([u64; N]); impl Bitfield { @@ -327,6 +314,17 @@ impl ProgramState { self.parameters.clear(); } + pub fn get_pseudo_cursor<'a>(&'a self, cursor_id: CursorID) -> &'a mut PseudoCursor { + let mut cursors = self.cursors.borrow_mut(); + let cursor = cursors + .get_mut(cursor_id) + .expect("cursor id out of bounds") + .as_mut() + .expect("cursor not allocated") + .as_pseudo_mut(); + unsafe { std::mem::transmute(cursor) } + } + pub fn get_sorter<'a>(&'a self, cursor_id: CursorID) -> &'a mut Sorter { let mut cursors = self.cursors.borrow_mut(); let cursor = cursors @@ -1087,7 +1085,7 @@ impl Program { } } CursorType::Pseudo(_) => { - let cursor = get_cursor_as_pseudo_mut(&mut cursors, *cursor_id); + let cursor = state.get_pseudo_cursor(*cursor_id); if let Some(record) = cursor.record() { state.registers[*dest] = record.get_value(*column).clone(); } else { @@ -1939,8 +1937,7 @@ impl Program { } }; state.registers[*dest_reg] = OwnedValue::Record(record.clone()); - let mut cursors = state.cursors.borrow_mut(); - let pseudo_cursor = get_cursor_as_pseudo_mut(&mut cursors, *pseudo_cursor); + let pseudo_cursor = state.get_pseudo_cursor(*pseudo_cursor); pseudo_cursor.insert(record); state.pc += 1; }