Remove some excessive RcBinding cloning

The cloning of an RcBinding is not needed when returning from a
surrounding method. This commit changes this code to use references
instead.
parent e62a4f8c
......@@ -77,8 +77,8 @@ impl Binding {
}
/// Returns the parent binding.
pub fn parent(&self) -> Option<RcBinding> {
self.parent.clone()
pub fn parent(&self) -> Option<&RcBinding> {
self.parent.as_ref()
}
/// Returns an immutable reference to the parent binding, `depth` steps up
......
......@@ -136,8 +136,8 @@ impl ExecutionContext {
self.global_scope.set(index, value);
}
pub fn binding(&self) -> RcBinding {
self.binding.clone()
pub fn binding(&self) -> &RcBinding {
&self.binding
}
/// Finds a parent context at most `depth` contexts up the ancestor chain.
......@@ -187,7 +187,7 @@ impl ExecutionContext {
current = parent;
}
&*current as *const Binding
&**current as *const Binding
}
pub fn binding_pointer(&self) -> *const Binding {
......
use crate::arc_without_weak::ArcWithoutWeak;
use crate::binding::RcBinding;
use crate::block::Block;
use crate::compiled_code::CompiledCodePointer;
use crate::config::Config;
......@@ -414,10 +413,6 @@ impl Process {
self.local_data_mut().mailbox.lock().receive()
}
pub fn binding(&self) -> RcBinding {
self.context().binding()
}
pub fn global_scope(&self) -> &GlobalScopePointer {
&self.context().global_scope
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment