Skip to content

Commit e9356cb

Browse files
authored
Merge pull request #51 from Tcode-Motion/jules-18031381421240302451-d36d1f22
⚡ Bolt: Optimize SQLite query map allocation
2 parents 599fa28 + e35c70b commit e9356cb

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

stdlib/src/sqlite.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,34 +166,13 @@ impl StdlibRegistry {
166166
.map(|i| stmt.column_name(i).unwrap_or("?").to_string())
167167
.collect();
168168

169-
let params_converted: Vec<rusqlite::types::Value> = params_list
170-
.iter()
171-
.map(|p| match p {
172-
RuntimeValue::Null => rusqlite::types::Value::Null,
173-
RuntimeValue::Bool(b) => {
174-
rusqlite::types::Value::Integer(if *b { 1 } else { 0 })
175-
}
176-
RuntimeValue::Int(i) => rusqlite::types::Value::Integer(*i),
177-
RuntimeValue::Float(f) => rusqlite::types::Value::Real(*f),
178-
RuntimeValue::Str(s) => rusqlite::types::Value::Text(s.clone()),
179-
_ => rusqlite::types::Value::Null,
180-
})
181-
.collect();
182-
183-
let params_refs: Vec<&dyn rusqlite::types::ToSql> = params_converted
184-
.iter()
185-
.map(|p| p as &dyn rusqlite::types::ToSql)
186-
.collect();
187169

188-
let mut rows = Vec::new();
189-
let row_iter = stmt
190-
<<<<<
191-
let mut map = IndexMap::new();
192170
for i in 0..col_count {
193-
let name = col_names[i].clone();
194171
let val: String =
195172
row.get::<_, String>(i).unwrap_or_default();
196-
map.insert(name, RuntimeValue::Str(val));
173+
if let Some((_, v)) = map.get_index_mut(i) {
174+
*v = RuntimeValue::Str(val);
175+
}
197176
}
198177
Ok(map)
199178
})

0 commit comments

Comments
 (0)