Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Tip of the day: (@)...[(R)...] is equal to (@M)...:#... and faster by 18-21%
- X-seq: zsh-users 22015
- From: <psprint@xxxxxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Tip of the day: (@)...[(R)...] is equal to (@M)...:#... and faster by 18-21%
- Date: Fri, 21 Oct 2016 08:59:56 +0000 (UTC)
- 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==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <536851559.167591.1477040396961.ref@mail.yahoo.com>
- Reply-to: <psprint@xxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author