From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2493 invoked by alias); 4 Dec 2015 17:34:07 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37308 Received: (qmail 24131 invoked from network); 4 Dec 2015 17:34:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=QD9glxBMqou2inqJFUVVfmPp0MEEfAPeUEpuTXP2oN8=; b=o5ctkoHFWEC5Ls6sebFqUlE3ZNArR74/6UVMZ1w9SToHLhHZKD9yPwlsC2eVaL+tyT XrXPUrnOuRBq22jbgWTaM4V4na3IJn2RJaYjIu2qN0UFg2XQ/YURLsTGH8kWWMqCvSZ3 2BhsA1qez7nx6zq7MZYBRr+oM5+Hg5nlO11mQ8T0j/Mm6Z46eiI+ezFiCir+aCY0fPtq KcCRM4rNlCIVzJxE3IKCei2WNVyqQVKUAUAG/ZMoDKUeHj1APXOmyxmm9/cnMw52IvSO bgdgoIoaCAw6KrxG1tkJAHsixtpPKGcakqQ+TKN76fOkxMkGk9U5BZLnKavWo2hqt+9o 7eoQ== X-Received: by 10.112.151.102 with SMTP id up6mr8699116lbb.44.1449250444121; Fri, 04 Dec 2015 09:34:04 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Sebastian Gniazdowski Date: Fri, 4 Dec 2015 18:33:44 +0100 Message-ID: Subject: Re: Single-run while makes script fast To: Zsh hackers list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I tested this on my two other scripts and it's speeding things up also there. Already commited the "optimizations": https://github.com/psprint/zsh-navigation-tools/commit/71fe5a2227a4e8a11687= 8194bf2bbb6db1bb8c25 Best regards, Sebastian Gniazdowski On 4 December 2015 at 17:20, Sebastian Gniazdowski wrote: > Hello, > I attach animated gif showing the effect. The while loop in following > code makes whole script fast: > > loop=3D1 > while (( loop -- )); do > filename=3D"lsoflsof" # 89k elements > body=3D( "${(@f)"$(<"$filename" )"}" ) > done > > Commenting out the loop and leaving only its body makes the whole script = slow: > > loop=3D1 > #while (( loop -- )); do > filename=3D"lsoflsof" # 89k elements > body=3D( "${(@f)"$(<"$filename" )"}" ) > #done > > This is reveals on Zsh 5.0.8 (OS X). On 5.2 it isn't visible or > doesn't actually occur =E2=80=93 because of recent optimizations. > > I wasn't able to reproduce this in some short script, but might yet > try to do this. I'm reporting because maybe there is something hidden > behind this. > > Best regards, > Sebastian Gniazdowski