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

Re: fix some distributed functions that depend on shortloops



On 4 March 2011 15:59, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Hmm, this one is a conundrum.  My first instinct would be to add -R to
> the "emulate" command at the top, rather than try to fix every native
> zsh-ism in the source; certainly that's correct for zargs, but it may
> not be for match-words-by-style if there are completion-related options
> that would be reset by that.
>
> OTOH -R is supposed to avoid changing options that affect the interactive
> behavior, so maybe it's a bug that emaulate -R changes e.g. completeinword.

Well, except for the first one, the changes are also improvements :).

skip=10000
% time ( repeat $skip charskip+=\? )
( repeat $skip; do; charskip+=\? ; done; )  0.07s user 0.00s system
97% cpu 0.071 total
% time ( charskip=${(l:skip::?:)} )
( charskip=${(l:skip::?:)} ; )  0.00s user 0.00s system 53% cpu 0.002 total
% time ( for (( i=1; i < 10000; i++ )) { } )
( for ((i=1; i < 10000; i++ )) do; ; done; )  0.01s user 0.00s system
93% cpu 0.015 total
% time ( for (( i=1; i < 10000; i++ )) : )
( for ((i=1; i < 10000; i++ )) do; :; done; )  0.02s user 0.01s system
96% cpu 0.031 total

Even if there is some better general way to fix this, I don't think
fixing stuff to not use short_loops hurts in any way. All other usages
of repeat already use the long form, though that may be because they
have larger bodies.

-- 
Mikael Magnusson



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