zsh-users/zsh-syntax-highlighting

Is optimization via integer-indexed hash possible?

Open

#366 aberto em 16 de set. de 2016

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)Shell (1.371 forks)batch import
good first issueperformance

Métricas do repositório

Stars
 (22.617 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

As Daniel pointed out, appends to region_highlight might be expensive. This reminded me coding https://github.com/psprint/zsh-morpho, where I used associative array indexed with integers instead of regular array. The image and needed array size is $LINES * $COLUMNS, say 6903 on my current terminal, which is not very large size, and when I compared hash vs array runs, it basically meant that with arrays one could go get a coffee multiple times. Maybe I'll provide numbers, but for hash it was ~7 seconds.

So, if highlighters would keep integer index=1, store at it into hash and increment, and then at the end move entries from hash into region_highlight at one go, this should improve performance.

PS. I checked region_highlight size produced by main-highlighter.zsh when parsing itself (754 lines), and its 686 entries, so not close to 6903, however we still might get 100 ms or more, which counts for zsyh-enabled vared and say 500 line functions edited with it (I already enable zsyh for vared).

Guia do colaborador