From b9146edc799af449708a14eb266e399cbb91458d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 13 Sep 2026 05:23:17 +0000 Subject: [PATCH] perf: avoid intermediate string allocation in VM debugger loop Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- runtime/vm/src/debugger.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/vm/src/debugger.rs b/runtime/vm/src/debugger.rs index 3817852f..df290a0b 100644 --- a/runtime/vm/src/debugger.rs +++ b/runtime/vm/src/debugger.rs @@ -55,7 +55,9 @@ impl VMDebugger { return; } - let op_str = format!("{:?}", op_code); + // Bolt performance optimization: Avoid unnecessary string allocation for op_code. + // `op_code` implements `Debug`, so we can format it directly into the final string + // instead of pre-allocating an intermediate String with `format!`. let mut operands_str = String::new(); for op in operands { @@ -93,8 +95,8 @@ impl VMDebugger { } println!( - "[{:04}] {:<15} {} | Stack: {:?}", - ip, op_str, operands_str, stack_dump + "[{:04}] {:<15?} {} | Stack: {:?}", + ip, op_code, operands_str, stack_dump ); } }