From ce798581d88c5be3508dea3b069bbd16c9da9aca Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2026 08:18:57 +0000 Subject: [PATCH] Optimize canvas aura string formatting Avoids allocating temporary strings per iteration by using `write!` instead of `format!`. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/canvas.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/src/canvas.rs b/stdlib/src/canvas.rs index d7dee547..644dd36a 100644 --- a/stdlib/src/canvas.rs +++ b/stdlib/src/canvas.rs @@ -1,6 +1,7 @@ use crate::{StdFunction, StdlibModule, StdlibRegistry}; use std::cell::RefCell; use std::collections::HashMap; +use std::fmt::Write; use std::rc::Rc; use techscript_runtime::{ context::RuntimeContext, error::RuntimeError, function::Callable, value::RuntimeValue, @@ -132,10 +133,11 @@ fn dsl_to_svg(val: &RuntimeValue, is_dragon: bool) -> String { for i in 0..count { let r = 80 + i as i64 * (size / 2); let opacity = 0.4 - (i as f32 * 0.08); - svg.push_str(&format!( + let _ = write!( + svg, r#""#, r, color, thickness, opacity - )); + ); } } "emblem" => {