zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: fast subshell
Date: Sun, 1 Apr 2018 13:45:46 -0700	[thread overview]
Message-ID: <c1e1d4a4-7dd3-2bfd-42dc-a1f0ea3753ae@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7Z=9t0hK2CGibSNfN=WWhZzNLq9MHP_N-+s05DgGhq5vQ@mail.gmail.com>

On 01/04/18 11:39 AM, Bart Schaefer wrote:
>
> It's quite possible that doing the memory management for the
> assignment to all_matches in a newly forked process is faster than in
> the original shell (perhaps because the subshell never needs to free
> it again?).  There is also some overhead involved in saving/restoring
> IFS with "local" which you are avoiding.
It's rather interesting.  I suppose the deepest gurus could actually 
discuss the nuts and bolts in detail.  Meanwhile my fears of some 
dreadful overhead are dead.
>
> Also there's really no reason to do both "local IFS=..." and
> "IFS=$OLD_IFS"
I need the thing restored for use latter in the same function. I've 
since seen that:

(
IFS=...
...
)

Somehow screws up, I'm not sure why but it has effects outside the 
parenthesis.  Issues with a subshell within a subshell?  Don't seem right.
>    (){ local IFS=$'\n'; all_matches=( $( whence -mavS $@ ) ) }
I'll try that.
> Or you can do it without changing IFS at all, like this:
>
>    all_matches=( ${(f)"$( whence -mavS $@ )"} )
>
Now that's the 'real' answer.  Direct control within the statement 
itself.   Gotta get used to these nested parameters, it's not really 
that scary.


      reply	other threads:[~2018-04-01 20:45 UTC|newest]

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

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=c1e1d4a4-7dd3-2bfd-42dc-a1f0ea3753ae@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).