Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Possible huge setarrvalue optimization



More, the optimization would apparently allow doing the following:

typeset -a arr
max_size=100
arr[max_size]=""

for (( i=1, i<=max_size, i ++ )); do
    arr[i]="some data"
done

I was haunted by current implementation when writing morphogenesis
screen saver (https://asciinema.org/a/47242), it has arrays that
represent coordinates on screen:

https://github.com/psprint/zsh-morpho/blob/5b84d919b5bbb7183ae78635adb995ab4c3ee7da/zmorpho#L11-L15

I've had to use integer-indexed hashes instead of regular arrays, which
were very slow. After the opt I will be able to test is-at-least 5.3 and
use regular arrays, maybe even pre-allocated with the `max_size`
solution.

-- 
  Sebastian Gniazdowski
  psprint@xxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author