diff --git a/src/ast/compiler/lambda_collector.rs b/src/ast/compiler/lambda_collector.rs index 41ad384..2a40d1e 100644 --- a/src/ast/compiler/lambda_collector.rs +++ b/src/ast/compiler/lambda_collector.rs @@ -33,7 +33,7 @@ impl<'a, T: Clone> LambdaCollector<'a, T> { if let BoundKind::Lambda { .. } = ¤t.kind { self.registry - .insert(*global_index, Rc::new((**current).clone())); + .insert(*global_index, (*current).clone()); } } self.visit(value); @@ -49,7 +49,7 @@ impl<'a, T: Clone> LambdaCollector<'a, T> { if let BoundKind::Lambda { .. } = ¤t.kind { self.registry - .insert(*global_index, Rc::new((**current).clone())); + .insert(*global_index, (*current).clone()); } } self.visit(value); diff --git a/src/ast/types.rs b/src/ast/types.rs index 234785d..fa51f46 100644 --- a/src/ast/types.rs +++ b/src/ast/types.rs @@ -67,6 +67,9 @@ impl NodeIdentity { pub struct Keyword(pub u32); static KEYWORD_REGISTRY: OnceLock>> = OnceLock::new(); +// We use String here instead of Arc because benchmarks (e.g. record_optimizations.myc) +// showed a 4% performance regression with Arc due to atomic overhead during formatting. +// Since name() is mostly used for diagnostics and UI, the deep clone is acceptable. static KEYWORD_REVERSE: OnceLock>> = OnceLock::new(); impl Keyword {