brackets: Optimize a tiny bit.
Compute «${#BUFFER}» just once. I haven't measured the effect of this, but it might just avoid a strlen() every time around the loop, which could add up for large ${BUFFER}s. See issue #295.
This commit is contained in:
parent
d4f8edc9f3
commit
b52a485c5c
@ -48,10 +48,11 @@ _zsh_highlight_brackets_highlighter()
|
|||||||
{
|
{
|
||||||
local level=0 pos
|
local level=0 pos
|
||||||
local -A levelpos lastoflevel matching typepos
|
local -A levelpos lastoflevel matching typepos
|
||||||
|
integer buflen=${#BUFFER}
|
||||||
region_highlight=()
|
region_highlight=()
|
||||||
|
|
||||||
# Find all brackets and remember which one is matching
|
# Find all brackets and remember which one is matching
|
||||||
for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do
|
for (( pos = 0; pos < buflen; pos++ )) ; do
|
||||||
local char="$BUFFER[pos+1]"
|
local char="$BUFFER[pos+1]"
|
||||||
case $char in
|
case $char in
|
||||||
["([{"])
|
["([{"])
|
||||||
@ -68,9 +69,9 @@ _zsh_highlight_brackets_highlighter()
|
|||||||
['"'\'])
|
['"'\'])
|
||||||
# Skip everything inside quotes
|
# Skip everything inside quotes
|
||||||
local quotetype=$char
|
local quotetype=$char
|
||||||
while (( $pos < ${#BUFFER} )) ; do
|
while (( pos < buflen )) ; do
|
||||||
(( pos++ ))
|
(( pos++ ))
|
||||||
[[ $BUFFER[$pos+1] == $quotetype ]] && break
|
[[ $BUFFER[pos+1] == $quotetype ]] && break
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
x
Reference in New Issue
Block a user