Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)

Sebastian Gniazdowski wrote on Thu, Feb 11, 2016 at 17:11:57 +0100:
> On 11 February 2016 at 11:43, Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> > That said, zsyh could be somewhat optimized if the ":howmany" syntax
> > would be utilized.
> Could came up with this:
> ./parse.zsh "zplugin.zsh" > out1.txt 128,78s user 8,61s system 99% cpu
> 2:17,85 total
> ./parse.zsh "zplugin.zsh" > out2.txt 74,34s user 8,38s system 99% cpu
> 1:23,12 total
> https://github.com/zsh-users/zsh-syntax-highlighting/pull/272

Thanks!  Merged, will be in 0.5.0.

However, I think avoiding the strlen() isn't the main benefit here:
I suspect the expression $buf[start_pos+1,-1], which is evaluated in
every iteration of the loop, might have triggered an O(N²) allocations
pattern, even before considering the implicit strlen for the -1 (or the
explicit strlen in the "else" branch).

The next step might be to see whether the two remaining instances of
that expression (one in the 'if' branch and one in the 'else' branch)
can also be simplified: for example, by precomputing the indices of all
newlines, semicolons, and starts-of-words (places where the regexp /\</
matches) in $buf.

Many thanks for your investigation!  I'd also like to thank Bart for his
help (some of which was offlist).


Messages sorted by: Reverse Date, Date, Thread, Author