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

Re: Optimizing (z)-flag



On Sun, Aug 11, 2019 at 11:21 AM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> I'm thinking: why the (z) flag runs significantly slower that a zsh
> executing the same script / text? It points that the cause should be
> the way that (z) stores resulting elements.

You're going to want to look at bufferwords in Src/hist.c.  If memory
allocation is the problem (of which I'm not convinced) it's probably
because the lexer discards some tokens while building the parse tree,
and bufferwords has to reconstruct the original text in some form,
which often means recopying the string values that the lexer does
return.  I don't think it's got very much to do with actually managing
the array, other than in the generic sense that parameter expansions
are done by value rather than by reference and therefore the source
array is copied yet again during final substitution.



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