adam-mcdaniel / dune

A shell🐚 by the beach🏖️!
https://adam-mcdaniel.net/dune-website
MIT License
1.01k stars 20 forks source link

Optimizations, correctly handle stdout #72

Open Aloso opened 3 years ago

Aloso commented 3 years ago

Fixes #71. Closes #70.

This PR adds a variable to the environment that tracks whether the currently evaluated expression's output should be printed directly or stored in a string. This is done to allow things like let x = which vim or "[" + (hostname ()) + "]".

I also refactored some parts to clone objects less often, allocate fewer Boxes and Vecs and use .to_string() instead of format!("{}", ..) when possible.

I replaced occurrences of impl ToString with impl Into<String> or just String, because ToString uses the Display implementation which might be more expensive.

cognivore commented 2 months ago

👀