Less memory allocations at runtime
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user