From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11341 invoked by alias); 5 Mar 2012 00:48:49 -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: X-Seq: 16837 Received: (qmail 11591 invoked from network); 5 Mar 2012 00:48:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.216.43 as permitted sender) Received-SPF: pass (google.com: domain of mikachu@gmail.com designates 10.224.214.68 as permitted sender) client-ip=10.224.214.68; Authentication-Results: mr.google.com; spf=pass (google.com: domain of mikachu@gmail.com designates 10.224.214.68 as permitted sender) smtp.mail=mikachu@gmail.com; dkim=pass header.i=mikachu@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=UVqgSDCl0W0KuxTnN4IRSEaxo/axSdd817xl4Ahk0/8=; b=oEPWtFdHyTajeOxdf3PR6Q7zZab7EKM/8RMftGzVk1Re2bck3bifJFOgkveao/AcHW VLljMKxsmJOkQb1mU+u8KNJtvSz5WukgC+V25NTq65cYO1poAu1ngTHd9xUWIRhL/ERl PaN/Sg2yjsBZjclV8fLFwmwv3o6sDCN/zZM+P4O3ikTnnDsyAdvUIwbCHjGJmV+8EOHW umWEeQjTobCUk698E0SNoZCaF9vPYBd6+KS9dVPF1SwF5jdiBaFjsNGFvzDDBTXtcYwX xifKJMzItyTS/9TXSJg/DNO3QHhclV9xHGf2ixF997zDTsAZulyaza/pbIfxIwr+vazN V4/g== MIME-Version: 1.0 In-Reply-To: <120304134721.ZM25119@torch.brasslantern.com> References: <20120304143102.GE18164@solfire> <120304103757.ZM24588@torch.brasslantern.com> <120304114412.ZM24769@torch.brasslantern.com> <120304134721.ZM25119@torch.brasslantern.com> Date: Mon, 5 Mar 2012 01:48:30 +0100 Message-ID: Subject: Re: if the file is not found the files is not found is the file not found From: Mikael Magnusson To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 4 March 2012 22:47, Bart Schaefer wrote: > On Mar 4, 9:13pm, Mikael Magnusson wrote: > } > } >> if () { (( $# )) } arglblargh*(N[1]); then echo yes; else echo no; fi > } > > } > (Also, the [1] in your formula is extraneous, but that's a nit.) > } > } I like to imagine that it causes less data to be copied around. :) > > According to valgrind, for a pattern matching six files the ([1]) saves > 3 mallocs and 3 frees but uses 346 *more* bytes of memory. "time" on > 10 runs of each shows no difference at all. > > The ([1]) does begin to win on memory as well when the number of matched > files grows, but even at 360+ files no difference in time is detectable, > probably because the vast bulk is taken up by doing the glob in the first > place. > > (e:'[ -f "$REPLY" ]':) takes about 3 times as long and uses 5 times as > much memory, with or without ([1]) added. (e:'[[ -f "$REPLY" ]]') is > better, only double time and triple memory, and is on a par with adding > (.) as a qualifier. > > So there you go. :-) Heh, thanks for checking :). Btw, % () { echo $# } * 2411 zsh -c 'repeat 1000 () { (($#)) } *' 6.53s user 0.40s system 98% cpu 6.999 total zsh -c 'repeat 1000 () { (($#)) } *([1])' 5.97s user 0.38s system 99% cpu 6.399 total (numbers are consistent within 0.02s) So maybe it doesn't save the time it takes to type the [1]. Adding oN on the other hand, zsh -c 'repeat 1000 () { (($#)) } *(oN)' 4.81s user 0.40s system 99% cpu 5.252 total zsh -c 'repeat 1000 () { (($#)) } *(oN[1])' 4.31s user 0.36s system 99% cpu 4.703 total For those that don't know, (oN) disables sorting the results of the glob. -- Mikael Magnusson