rune-rs / rune

An embeddable dynamic programming language for Rust.
https://rune-rs.github.io
Apache License 2.0
1.7k stars 85 forks source link

rune: Allow empty values to be const constructed #744

Closed udoprog closed 1 month ago

udoprog commented 1 month ago

This change improves performance across most of our benchmarks by around 10%.

The idea here is that we want Value to have a cheap, non-allocating empty implementation. When slots are initializing they are filled with these empty values and previously they would all have to be allocated.

This also means that dropping values does not require you to allocate a new value to replace it.

This change means that there is an empty value representation which is cheap to initialize and clone.