Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Substitution ${...///} slows down when certain UTF character occurs

On 27 September 2015 at 18:11, Bart Schaefer
> It'll get worse if there are partial matches, e.g., if you had 30000
> repetitions of "wfei" and scanned for "wfeiwj" there'd be a whole lot
> of backtracking.  There are no "w" anywhere in your sample $str so
> each of the comparisons is only one equality test.

It's still instant fast for 30k of wfei (attached is the script). I
also tried generating a [wfeiwj]-only string, and it's also fast:

cat /dev/urandom | env LC_CTYPE=C tr -cd 'wfeiwj' | head -c 120000 > input

Gave it one more try with
"wfeiwjwoiejfowiejfowijefoiwjefoiwjefoijwoeifjwoiejf" (30k of it, and
was searching for it) and it becomes slower (times 0.15s instead of
0.012s) but is still instant fast.

> Still I think the biggest issue is that unmetafication happening too
> low down.  Since pattry*() is being called repeatedly with the same two
> first arguments (prog and string) it might be possible to cache the
> unmetafied string after the first call.

I wonder why it depends on Zsh version and/or environment (OS, etc.).
This doesn't seem related to unmetafication, unless it was changed
after 5.0.2.

Best regards,
Sebastian Gniazdowski

Attachment: test-script.zsh
Description: Binary data

Messages sorted by: Reverse Date, Date, Thread, Author