mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-01-30 09:47:13 +08:00
brackets: Optimize the character iteration
Test case: See the first comment of issue #295. Before: num calls time self name ----------------------------------------------------------------------------------- 1) 14 284.67 20.33 82.84% 284.67 20.33 82.84% _zsh_highlight_highlighter_brackets_paint 2) 15 313.72 20.91 91.30% 26.62 1.77 7.75% _zsh_highlight 3) 14 318.68 22.76 92.74% 7.41 0.53 2.16% _zsh_highlight_call_widget After: num calls time self name ----------------------------------------------------------------------------------- 1) 15 57.25 3.82 45.33% 28.30 1.89 22.41% _zsh_highlight 2) 14 81.96 5.85 64.90% 27.02 1.93 21.40% _zsh_highlight_call_widget 3) 14 26.31 1.88 20.84% 26.31 1.88 20.84% _zsh_highlight_highlighter_brackets_paint 4) 2 10.66 5.33 8.44% 8.97 4.49 7.10% VCS_INFO_formats 5) 2 25.92 12.96 20.52% 7.72 3.86 6.11% VCS_INFO_get_data_git (That's not in my everyday configuration but in my minimal testing setup, which runs vcs_info with the default settings.)
This commit is contained in:
parent
d62baa50f4
commit
cdd7f899cb
@ -112,6 +112,8 @@ to issue #418.
|
|||||||
revision zsh-5.8-172-gdd6e702ee or newer is also fine.)
|
revision zsh-5.8-172-gdd6e702ee or newer is also fine.)
|
||||||
[#418, https://github.com/okapia/zsh-viexchange/issues/1]
|
[#418, https://github.com/okapia/zsh-viexchange/issues/1]
|
||||||
|
|
||||||
|
- Improve performance of the `brackets` highlighter.
|
||||||
|
|
||||||
|
|
||||||
# Changes in version 0.7.1
|
# Changes in version 0.7.1
|
||||||
|
|
||||||
|
@ -51,8 +51,9 @@ _zsh_highlight_highlighter_brackets_paint()
|
|||||||
local -A levelpos lastoflevel matching
|
local -A levelpos lastoflevel matching
|
||||||
|
|
||||||
# Find all brackets and remember which one is matching
|
# Find all brackets and remember which one is matching
|
||||||
for (( pos = 1; pos <= buflen; pos++ )) ; do
|
pos=0
|
||||||
char=$BUFFER[pos]
|
for char in ${(s..)BUFFER} ; do
|
||||||
|
(( ++pos ))
|
||||||
case $char in
|
case $char in
|
||||||
["([{"])
|
["([{"])
|
||||||
levelpos[$pos]=$((++level))
|
levelpos[$pos]=$((++level))
|
||||||
|
Loading…
Reference in New Issue
Block a user