zsh-users
 help / color / mirror / code / Atom feed
* fast subshell
@ 2018-04-01 15:59 Ray Andrews
  2018-04-01 18:39 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Ray Andrews @ 2018-04-01 15:59 UTC (permalink / raw)
  To: Zsh Users

So, now that I am awake to the usefulness of subshells in a function, 
I'm still exploring the implications on speed since a subshell sounds 
like it would be a lot of work.  However, using it to  control my old 
friend IFS, whereasI had previously done this:


     local IFS=$'\n' # Must split on newlines only.
     all_matches=( $( whence -mavS $@ ) )
     IFS=$OLD_IFS

... now trying:


(
     IFS=$'\n' # Must split on newlines only.
     all_matches=( $( whence -mavS $@ ) )
)

... and the interesting thing is that the former executes a stress test 
in ca. 290 mS, but the latter in ca. 250 mS.  The difference isn't 
significant in the real world, but it is hard to understand, it seems 
strange that the subshell would be faster. Is this possible?  If so, how 
should I understand it?  It seems as if a subshell is a rather 'lite' 
thing after all, in the above it seems to be hardly more than a scoping 
of IFS.


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

end of thread, other threads:[~2018-04-01 20:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01 15:59 fast subshell Ray Andrews
2018-04-01 18:39 ` Bart Schaefer
2018-04-01 20:45   ` Ray Andrews

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).