zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: fast subshell
Date: Sun, 1 Apr 2018 08:59:16 -0700	[thread overview]
Message-ID: <df6bc2d6-48ad-d491-355b-0228a4c6e503@eastlink.ca> (raw)

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.


             reply	other threads:[~2018-04-01 15:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01 15:59 Ray Andrews [this message]
2018-04-01 18:39 ` Bart Schaefer
2018-04-01 20:45   ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df6bc2d6-48ad-d491-355b-0228a4c6e503@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).