Fix: Remove unnecessary Rc::new from LambdaCollector
The `LambdaCollector` was cloning nodes and wrapping them in `Rc`. However, the `registry` itself is already holding `Rc` clones of the nodes. This commit removes the redundant `Rc::new` to simplify the code. This change also addresses a performance regression observed in benchmarks due to unnecessary atomic overhead from `Arc` in the `Keyword` type.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user