From 0368aea5da19bbdabcbeedf85a443e07ed0f03e2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:14:08 +0000 Subject: [PATCH] Code health: Pre-allocate row map capacity and document necessary clone in database.rs Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/database.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/src/database.rs b/stdlib/src/database.rs index 15987f53..ace1f203 100644 --- a/stdlib/src/database.rs +++ b/stdlib/src/database.rs @@ -130,7 +130,7 @@ fn std_database_query( None, ) })? { - let mut row_map = IndexMap::new(); + let mut row_map = IndexMap::with_capacity(column_names.len()); for (idx, name) in column_names.iter().enumerate() { let value = match row.get_ref(idx).map_err(|e| { RuntimeError::new( @@ -151,6 +151,8 @@ fn std_database_query( RuntimeValue::Str(s) } }; + // The clone here is strictly necessary because `IndexMap` requires an owned `String` + // key, and each row constructs a fresh map containing these keys. row_map.insert(name.clone(), value); } result_rows.push(RuntimeValue::Map {