From cdd7f899cb9aae7b5a39729d3b5aab33f89b4f6f Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 14 Jul 2020 20:15:50 +0000 Subject: [PATCH 1/3] 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.) --- changelog.md | 2 ++ highlighters/brackets/brackets-highlighter.zsh | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index daeda05..cc3153e 100644 --- a/changelog.md +++ b/changelog.md @@ -112,6 +112,8 @@ to issue #418. revision zsh-5.8-172-gdd6e702ee or newer is also fine.) [#418, https://github.com/okapia/zsh-viexchange/issues/1] +- Improve performance of the `brackets` highlighter. + # Changes in version 0.7.1 diff --git a/highlighters/brackets/brackets-highlighter.zsh b/highlighters/brackets/brackets-highlighter.zsh index fc71f2a..bc388fd 100644 --- a/highlighters/brackets/brackets-highlighter.zsh +++ b/highlighters/brackets/brackets-highlighter.zsh @@ -51,8 +51,9 @@ _zsh_highlight_highlighter_brackets_paint() local -A levelpos lastoflevel matching # Find all brackets and remember which one is matching - for (( pos = 1; pos <= buflen; pos++ )) ; do - char=$BUFFER[pos] + pos=0 + for char in ${(s..)BUFFER} ; do + (( ++pos )) case $char in ["([{"]) levelpos[$pos]=$((++level)) From 00a5fd11eb9d1c163fb49da5310c8f4b09fb3022 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 14 Jul 2020 21:05:34 +0000 Subject: [PATCH 2/3] Tag version 0.8.0-alpha1-pre-redrawhook. --- .version | 2 +- changelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.version b/.version index c7d2522..41c20b3 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.7.2-dev +0.8.0-alpha1-pre-redrawhook diff --git a/changelog.md b/changelog.md index cc3153e..96ad507 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,4 @@ -# Changes in HEAD +# Changes in 0.8.0-alpha1-pre-redrawhook ## Notice about an improbable-but-not-impossible forward incompatibility From 2d60a47cc407117815a1d7b331ef226aa400a344 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 20 Oct 2015 14:35:21 +0000 Subject: [PATCH 3/3] Post-release version number bump. --- .version | 2 +- changelog.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.version b/.version index 41c20b3..9fb1210 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.8.0-alpha1-pre-redrawhook +0.8.0-alpha2-dev diff --git a/changelog.md b/changelog.md index 96ad507..518d6a8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# Changes in HEAD + + # Changes in 0.8.0-alpha1-pre-redrawhook ## Notice about an improbable-but-not-impossible forward incompatibility