Less memory allocations at runtime
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::{Arc, LazyLock};
|
||||
|
||||
use super::ops::Op;
|
||||
use super::theory;
|
||||
@@ -3031,7 +3031,7 @@ pub(super) fn compile_word(
|
||||
// @varname - fetch variable
|
||||
if let Some(var_name) = name.strip_prefix('@') {
|
||||
if !var_name.is_empty() {
|
||||
ops.push(Op::PushStr(var_name.to_string(), span));
|
||||
ops.push(Op::PushStr(Arc::from(var_name), span));
|
||||
ops.push(Op::Get);
|
||||
return true;
|
||||
}
|
||||
@@ -3040,7 +3040,7 @@ pub(super) fn compile_word(
|
||||
// !varname - store into variable
|
||||
if let Some(var_name) = name.strip_prefix('!') {
|
||||
if !var_name.is_empty() {
|
||||
ops.push(Op::PushStr(var_name.to_string(), span));
|
||||
ops.push(Op::PushStr(Arc::from(var_name), span));
|
||||
ops.push(Op::Set);
|
||||
return true;
|
||||
}
|
||||
@@ -3073,6 +3073,6 @@ pub(super) fn compile_word(
|
||||
}
|
||||
|
||||
// Unrecognized token becomes a string
|
||||
ops.push(Op::PushStr(name.to_string(), span));
|
||||
ops.push(Op::PushStr(Arc::from(name), span));
|
||||
true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user