bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: efficient way to use matched string in variable substitution


From: Mike Jonkmans
Subject: Re: efficient way to use matched string in variable substitution
Date: Tue, 24 Aug 2021 16:41:46 +0200

On Tue, Aug 24, 2021 at 09:24:35AM -0400, Greg Wooledge wrote:
> On Tue, Aug 24, 2021 at 03:09:55PM +0200, Mike Jonkmans wrote:
> > This seems to be the fastest:
> > f12 () { [[ "$1" =~ ${1//?/(.)} ]]; local arr=( "${BASH_REMATCH[@]:1}" ); }
> > time for ((i=1; i<=10000; i++)); do f0 682390; done
> > real    0m0,296s
> > user    0m0,296s
> > sys     0m0,000s
> 
> Your CPU is a bit faster than mine, since none of mine (nor yours) go
> quite that fast on my computer, but you've written "f0" in your time
> command, not f12.

oh oh, last minute edit - because i wasn't sure at which fN you started :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]