From c793baeadd2bd290bf1aba0cf522e79cde51fa7a Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Fri, 4 Dec 2015 19:51:09 +0100 Subject: [PATCH] znt: optimize heap usage for older Zsh's (e.g. 5.0.8) --- plugins/zsh-navigation-tools/n-list | 6 +++++- plugins/zsh-navigation-tools/n-panelize | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list index 0a98d86e1..55c08515b 100644 --- a/plugins/zsh-navigation-tools/n-list +++ b/plugins/zsh-navigation-tools/n-list @@ -224,7 +224,11 @@ zcurses timeout main -1 key="" keypad="" -list=( "$@" ) +# This loop makes script faster on some Zsh's (e.g. 5.0.8) +repeat 1; do + list=( "$@" ) +done + last_element="$#list" while (( 1 )); do diff --git a/plugins/zsh-navigation-tools/n-panelize b/plugins/zsh-navigation-tools/n-panelize index a70565c79..01d01cb9e 100644 --- a/plugins/zsh-navigation-tools/n-panelize +++ b/plugins/zsh-navigation-tools/n-panelize @@ -32,7 +32,11 @@ if [ -t 0 ]; then return 1 fi - list=( `"$@"` ) + # This loop makes script faster on some Zsh's (e.g. 5.0.8) + repeat 1; do + list=( `"$@"` ) + done + # TODO: $? doesn't reach user [ "$?" -eq 127 ] && return $? else @@ -42,7 +46,10 @@ else return 1 fi - list=( "${(@f)"$(<&0)"}" ) + # This loop makes script faster on some Zsh's (e.g. 5.0.8) + repeat 1; do + list=( "${(@f)"$(<&0)"}" ) + done if [[ ! -c /dev/tty ]]; then exec <&2