Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)
From: Bart Schaefer <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Wed, 10 Feb 2016 10:18:46 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Feb 10,  5:32pm, Sebastian Gniazdowski wrote:
}
} Isn't it that zsyh does a fork for each token it analyzes?

_zsh_highlight_main__type does appear to be called slightly more often
than once per line on a sample function body.  However it doesn't take
much time:

1.602947000e+00 local res="$(_zsh_highlight_main__type ${expanded_arg})"
1.603546000e+00 _zsh_highlight_main__type ${expanded_arg}
1.603900000e+00 if (( $#options_to_set )) ; then ; setopt $options_to_set ; fi
1.603988000e+00 (( $#options_to_set ))
1.604063000e+00 LC_ALL=C builtin type -w -- $1 2> /dev/null
1.604682000e+00

That's 0.001735 seconds per call on my system.  Not enough to account by
itself for the noticeable delay, I think.  It's true that most of that
time is managing the fork -- each call could be be 0.0012 or so faster
without forking -- but I'd still be surprised if that clears it all up.