Kevin27954 / Pace_Honor_Thesis

This would be my honor thesis for pace, where I create an interpreted language for beginners.
0 stars 0 forks source link

.clone() #10

Open Kevin27954 opened 1 month ago

Kevin27954 commented 1 month ago

We still have a few areas that are using .clone() in vm.rs. This isn't wanted as we want to maximize the performance during runtime.

Right now, the areas that require the .clone() is due to the stack being of type Vec<Value>. Since it requires a ownership or a direct reference to it on the Rust Stack, we need to clone to satisfy the type checker. Look into ways where we can remove the need to create an entire copy of the value since sometimes we might have functions as part of those values, and they can be pretty big.

Kevin27954 commented 1 month ago

One way is potentially making the stack of type Vec<Rc<Value>>.

With this, we can just have the reference to it but never lose it as long as one person or value has reference to it. It also creates a new reference to it when you do .clone() so the performance is much better than before.