From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27838 invoked by alias); 21 Oct 2016 09:09:47 -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: 22015 Received: (qmail 26873 invoked from network); 21 Oct 2016 09:09:47 -0000 X-Qmail-Scanner-Diagnostics: from nm45-vm5.bullet.mail.gq1.yahoo.com 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(67.195.87.163):SA:0(-0.3/5.0):. Processed in 0.121532 secs); 21 Oct 2016 09:09:47 -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=-0.3 required=5.0 tests=FREEMAIL_FROM,RP_MATCHES_RCVD, SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint@yahoo.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 67.195.87.163 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1477040607; bh=pDS2GlmmWwcE0scSsDB/POu2U4BmOgR3rB33EoGlJUg=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=cqgvzSyTX0kPQj6axN86UjmfLdlIE3EFAaWLl5wc4Twnn1ZtqOjzxAqyRlHRI7HlTS6U4q7xyCWLLzLB9hohRYj5Q7nTbeISybvQmQXByMFJvRk98nwWMOXuMQj6X5Y+jx4qibZ/v3UfXLyiG3U1xmPiTN1A08mn3uuY7+WQmXJ2H+fMVHYB/AfU5Cr7+Dv9JqSYD4s1SnnneyDjfAlt6q1cqsNE8+B+atCuAmZ8X1uXxoBxE2fVVX6YK3+lQDGonprVlwyYQ3U/m4HCT5C6IN7eg+RFmls0lEq6+0hIDcQ8ucdhzIzHz5hMAZjVkC5sQQ1vLlxflt9zpW1brhOyjg== X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 339337.90070.bm@omp1047.mail.gq1.yahoo.com X-YMail-OSG: p8m4GPgVM1lvb5MgPNxeWfjPsSflC8rbWASct8W2Fi4wdcxReg_OCn3847YwjzY v90ZGrh14SlHS.rkRyi3lflLMQNxCzymQG_Ru6yIqqZCP9oXzT_MnpYZ6Qrzz.a0vSuVwlw2uJzi VMmHcOeuLyZB9aOQneWbM3IlZxR1njyRbOO8cGMtXGnOlfWuOr_L.2cjlYrUGmMsArwYVHn0SOxk rWK_crUfHz58W0zVcJkf6uQT7URa2M_D1NEJPIvbjtJQ5UKGnp0bIZHZuUAEFVfqqJwuZr.20.6h BwnZfCP8XuZCOoy6nXj8jJP0TPJEWoMY4qRCG814ck5oSsSvZi1GPbeb_drClQ1V5_Mp32m.etWB V4GXwaLW5PDg2H6aXPW8ZR0KxMid6dHZb_XoOCLaF.osVI.RPJLbIO.yXSLG_mSTrjjPAvqwUeaX rWR8NYhYgwPNWX.0itRbCc8XNzmzfKGs4msnKeMlkD0bQo5fWBVLQHIc7Qy9QDCkVzqPrtIZ1Z0Y NdJmc.JA87_0Z2_k.rDGs1Sc4DZyKlhrUrHagZOz2Q6v1NlIK7g-- Date: Fri, 21 Oct 2016 08:59:56 +0000 (UTC) From: Reply-To: To: "zsh-users@zsh.org" Message-ID: <536851559.167591.1477040396961@mail.yahoo.com> Subject: Tip of the day: (@)...[(R)...] is equal to (@M)...:#... and faster by 18-21% MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit References: <536851559.167591.1477040396961.ref@mail.yahoo.com> Hello, I've discovered that following code: found=( "${(@M)history:#(#i)*$~search_pattern*}" ) can be replaced by: found=( "${(@)history[(R)(#i)*$~search_pattern*]}" ) and the speeds are: 215 ms vs. 175 ms, for "(#i)**" final pattern, ${#history[@]} == 89000, and typeset -U found (resolving to 18500 entries). Performing sequence of searches for word "h", "hi", "his", ..., "history" gives accumulated times 1271 ms vs. 1000 ms, difference is ~ 7*40ms, in check. Measured via zprof, by wrapping block of code with () { ... }. I wonder if there are there any pitfalls in such replacement? Best regards, Sebastian Gniazdowski