Less memory allocations at runtime

This commit is contained in:
2026-02-02 21:55:10 +01:00
parent cd8182425a
commit 74fe999496
9 changed files with 146 additions and 457 deletions

View File

@@ -128,7 +128,7 @@ fn forget_removes_word() {
let stack = f.stack();
assert_eq!(stack.len(), 1);
match &stack[0] {
Value::Str(s, _) => assert_eq!(s, "double"),
Value::Str(s, _) => assert_eq!(s.as_ref(), "double"),
other => panic!("expected Str, got {:?}", other),
}
}

View File

@@ -46,7 +46,7 @@ fn float_literal() {
fn string_with_spaces() {
let f = run(r#""hello world" !x @x"#);
match stack_top(&f) {
cagire::forth::Value::Str(s, _) => assert_eq!(s, "hello world"),
cagire::forth::Value::Str(s, _) => assert_eq!(s.as_ref(), "hello world"),
other => panic!("expected string, got {:?}", other),
}
}

View File

@@ -90,7 +90,7 @@ pub fn expect_int(script: &str, expected: i64) {
}
pub fn expect_str(script: &str, expected: &str) {
expect_stack(script, &[Value::Str(expected.to_string(), None)]);
expect_stack(script, &[Value::Str(Arc::from(expected), None)]);
}
pub fn expect_float(script: &str, expected: f64) {