Optimize searching in $history by 18-21%, via (R) index flag

This commit is contained in:
Sebastian Gniazdowski 2016-10-21 11:06:44 +02:00
parent 84b7b4b7c8
commit 25d593ec29

View file

@ -70,7 +70,9 @@ _hsmw_main() {
if [ "$#__hsmw_hcw_found" -eq "0" ]; then
# The repeat will make the matching work on a fresh heap arena
repeat 1; do
__hsmw_hcw_found=( "${(@M)history:#(#i)*$~search_pattern*}" )
# Tip: these are equal:
#__hsmw_hcw_found=( "${(@M)history:#(#i)*$~search_pattern*}" )
__hsmw_hcw_found=( "${(@)history[(R)(#i)*$~search_pattern*]}" )
done
fi