Less memory allocations at runtime

This commit is contained in:
2026-02-02 21:55:10 +01:00
parent 194030d953
commit 8024c18bb0
9 changed files with 146 additions and 457 deletions

View File

@@ -1,6 +1,7 @@
use rand::rngs::StdRng;
use rand::{Rng as RngTrait, SeedableRng};
use std::borrow::Cow;
use std::sync::Arc;
use super::compiler::compile_script;
use super::ops::Op;
@@ -423,7 +424,7 @@ impl Forth {
let val = if values.len() == 1 {
values.into_iter().next().unwrap()
} else {
Value::CycleList(values)
Value::CycleList(Arc::from(values))
};
cmd.set_sound(val);
}
@@ -435,7 +436,7 @@ impl Forth {
let val = if values.len() == 1 {
values.into_iter().next().unwrap()
} else {
Value::CycleList(values)
Value::CycleList(Arc::from(values))
};
cmd.set_param(param.clone(), val);
}
@@ -735,7 +736,7 @@ impl Forth {
} else {
let key = format!("__chain_{}_{}__", ctx.bank, ctx.pattern);
let val = format!("{bank}:{pattern}");
self.vars.lock().unwrap().insert(key, Value::Str(val, None));
self.vars.lock().unwrap().insert(key, Value::Str(Arc::from(val), None));
}
}