yash-rs icon indicating copy to clipboard operation
yash-rs copied to clipboard

Possibly more efficient structure of variable set

Open magicant opened this issue 3 years ago • 2 comments

Currently, VariableSet has a hash map to store variables where keys are variable name strings and values are vectors of pairs of a variable definition and context index. This structure requires vector allocation for each variable name.

It may be more efficient to use a tree map with keys being pairs of a variable name and context index and values being variable definitions.

TODO: Does this idea go well with the usage of Borrow for key comparison?

magicant avatar Apr 10 '22 11:04 magicant

Another idea is to store a variable name and value in a single C string of the form name=value (or name=colon:separated:array:values). This will reduce allocation in env_c_strings.

TODO: How do we handle unwanted null bytes in the middle of a string?

magicant avatar Apr 11 '22 15:04 magicant