magicant / yash-rs

Reimplementation of yash, an extended POSIX shell
63 stars 3 forks source link

Possibly more efficient structure of variable set #150

Open magicant opened 2 years ago

magicant commented 2 years ago

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 commented 2 years ago

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?