zsh-workers
 help / color / mirror / code / Atom feed
* fix some distributed functions that depend on shortloops
@ 2011-03-04 12:17 Mikael Magnusson
  2011-03-04 14:59 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2011-03-04 12:17 UTC (permalink / raw)
  To: zsh workers

http://cgit.mika.l3ib.org/cgit/zsh-cvs/patch/?id=1067eea1d44eda8e0c342bc8253fb6ce5075e0b3

diff --git a/Functions/Misc/zargs b/Functions/Misc/zargs
index 58d8461..8350b1a 100644
--- a/Functions/Misc/zargs
+++ b/Functions/Misc/zargs
@@ -207,7 +207,7 @@ then
     else
 	call=($command)
 	# Use "repeat" here so "continue" won't complain.
-	repeat 1 eval "$execute ; $analyze"
+	repeat 1; do eval "$execute ; $analyze"; done
 	return $ret
     fi
 fi
@@ -273,7 +273,7 @@ do
     repeat $P
     do
 	((ARGC)) || break
-	for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) :
+	for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) { }
 	(( end > n && ( end = n ) ))
 	args=( $argv[1,end] )
 	shift $((end > ARGC ? ARGC : end))
diff --git a/Functions/Zle/match-words-by-style
b/Functions/Zle/match-words-by-style
index 69ceba7..b387828 100644
--- a/Functions/Zle/match-words-by-style
+++ b/Functions/Zle/match-words-by-style
@@ -220,8 +220,7 @@ if [[ $wordstyle = *subword* ]]; then
 fi

 match=()
-charskip=
-repeat $skip charskip+=\?
+charskip=${(l:skip::?:)}

 eval pat2='${RBUFFER##(#b)('${charskip}${spacepat}')('\
 ${wordpat2}')('${spacepat}')}'

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix some distributed functions that depend on shortloops
  2011-03-04 12:17 fix some distributed functions that depend on shortloops Mikael Magnusson
@ 2011-03-04 14:59 ` Bart Schaefer
  2011-03-16 15:10   ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2011-03-04 14:59 UTC (permalink / raw)
  To: zsh workers

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix some distributed functions that depend on shortloops
  2011-03-04 14:59 ` Bart Schaefer
@ 2011-03-16 15:10   ` Mikael Magnusson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2011-03-16 15:10 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh workers

On 4 March 2011 15:59, Bart Schaefer <schaefer@brasslantern.com> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-16 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-04 12:17 fix some distributed functions that depend on shortloops Mikael Magnusson
2011-03-04 14:59 ` Bart Schaefer
2011-03-16 15:10   ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).