From: Sebastian Gniazdowski <psprint@fastmail.com>
To: zsh-users@zsh.org
Subject: Re: Match to the end of string when using (S) flag
Date: Tue, 01 Nov 2016 11:29:35 -0700 [thread overview]
Message-ID: <1478024975.3113621.774078481.323B1F9E@webmail.messagingengine.com> (raw)
In-Reply-To: <1478017673.3085741.773974873.7C58DD0B@webmail.messagingengine.com>
A miracle optimization – via mathematical function!
__hsmw_region_highlight_data=( )
: "${text//(#mi)(${~colsearch_pattern})/$(( append(MBEGIN,MEND) ))}"
region_highlight+=( $__hsmw_region_highlight_data )
shappend() {
__hsmw_region_highlight_data+=( "$(( offset + $1 - 1 )) $((
offset + $2 )) ${__hsmw_hl_color}" )
}
functions -M append 2 2 shappend
This gives total time (time of anonymous function wrapping first three
lines) for a complex – three-word A|B|C – input pattern: 44 ms (17 ms in
shappend).
When I do:
: "${(S)text//*(#bi)(${~colsearch_pattern})/$((
append(mbegin[1],mend[1]) ))}"
then the time is: 528 ms ! After removing leading star *: 52 ms (18 ms
in shappend).
Time of original one-liner without math-function call: 502 ms.
--
Sebastian Gniazdowski
psprint@fastmail.com
next prev parent reply other threads:[~2016-11-01 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 14:25 Sebastian Gniazdowski
2016-11-01 16:27 ` Sebastian Gniazdowski
2016-11-01 18:29 ` Sebastian Gniazdowski [this message]
2016-11-01 21:23 ` Bart Schaefer
2016-11-02 6:53 ` Sebastian Gniazdowski
2016-11-02 15:50 ` Bart Schaefer
2016-11-02 9:46 ` Peter Stephenson
2018-11-07 12:30 ` Sebastian Gniazdowski
2018-11-07 15:25 ` Bart Schaefer
2018-11-07 17:16 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1478024975.3113621.774078481.323B1F9E@webmail.messagingengine.com \
--to=psprint@fastmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).