From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14733 invoked by alias); 1 Apr 2018 20:45:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23303 Received: (qmail 24913 invoked by uid 1010); 1 Apr 2018 20:45:53 -0000 X-Qmail-Scanner-Diagnostics: from mta04.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.10):SA:0(-2.6/5.0):. Processed in 1.338665 secs); 01 Apr 2018 20:45:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=dfKuI0fe c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=OFb2D-3P4MtSXqFCnQgA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 Subject: Re: fast subshell To: zsh-users@zsh.org References: From: Ray Andrews Message-id: Date: Sun, 1 Apr 2018 13:45:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-reply-to: Content-language: en-CA 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.