mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-28 04:14:34 +01:00
Merge 'core: Fix Statement::reset()' from Pekka Enberg
The first rule of writing fast programs: don't use dynamic memory allocation! Brings `SELECT 1` micro-benchmark back to 70 ns, which is a bit closer to what we had before. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #781
This commit is contained in:
@@ -486,8 +486,7 @@ impl Statement {
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
let state = vdbe::ProgramState::new(self.program.max_registers);
|
||||
self.state = state
|
||||
self.state.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,6 +258,19 @@ impl ProgramState {
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.pc = 0;
|
||||
self.btree_table_cursors.borrow_mut().clear();
|
||||
self.btree_index_cursors.borrow_mut().clear();
|
||||
self.pseudo_cursors.borrow_mut().clear();
|
||||
self.sorter_cursors.borrow_mut().clear();
|
||||
let max_registers = self.registers.len();
|
||||
self.registers.clear();
|
||||
self.registers.resize(max_registers, OwnedValue::Null);
|
||||
self.last_compare = None;
|
||||
self.deferred_seek = None;
|
||||
self.ended_coroutine.clear();
|
||||
self.regex_cache.like.clear();
|
||||
self.interrupted = false;
|
||||
self.parameters.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user