feat: less clone on symbol

This commit is contained in:
2025-05-15 18:19:16 +08:00
parent 3e7a8a1c05
commit 864be73e77
12 changed files with 195 additions and 183 deletions

View File

@@ -1,6 +1,5 @@
use std::rc::Rc;
use ecow::EcoString;
use itertools::Itertools;
use rpds::HashTrieMap;
use derive_more::Constructor;
@@ -13,11 +12,11 @@ use crate::vm::{Env, VM};
#[derive(Debug, Clone)]
pub enum Param {
Ident(EcoString),
Ident(usize),
Formals {
formals: Vec<(EcoString, Option<usize>)>,
formals: Vec<(usize, Option<usize>)>,
ellipsis: bool,
alias: Option<EcoString>,
alias: Option<usize>,
},
}
@@ -69,7 +68,7 @@ impl<'vm> Func<'vm> {
&& arg
.as_inner()
.iter()
.map(|(k, _)| k.as_inner())
.map(|(k, _)| k)
.sorted()
.ne(formals.iter().map(|(k, _)| k).sorted())
{
@@ -78,7 +77,7 @@ impl<'vm> Func<'vm> {
for (formal, default) in formals {
let formal = formal.clone().into();
let arg = arg
.select(&formal)
.select(formal)
.or_else(|| default.map(|idx| Value::Thunk(Thunk::new(vm.get_thunk(idx)))))
.unwrap();
new.insert_mut(formal, arg);