fish-shell/src/builtins/string
Mahmoud Al-Qudsi 93f8385448 Add option to speed up string match/replace with --max-matches
I've often needed a way to get the last bit of performance out of unwieldy
completions that involve a lot of string processing (apt completions come to
mind, and I ran into it just now with parsing man pages for kldload
completions).

Since many times we are looking for just one exact string in the haystack, an
easy optimization here is to introduce a way for `string match` or `string
replace` to early exit after a specific number of matches (typically one) have
been found.

Depending on the size of the input, this can be a huge boon. For example,
parsing the description from FreeBSD kernel module man pages with

    zcat /usr/share/man/man4/zfs.4.gz | string match -m1 '.Nd *'

runs 35% faster with -m1 than without, while processing all files under
/usr/share/man/man4/*.4.gz in a loop (so a mix of files ranging from very short
to moderately long) runs about 10% faster overall with -m1.
2024-06-30 17:51:50 -05:00
..
collect.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
escape.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
join.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
length.rs Apply some clippy lints 2024-05-26 10:37:37 +02:00
match.rs Add option to speed up string match/replace with --max-matches 2024-06-30 17:51:50 -05:00
pad.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
repeat.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
replace.rs Add option to speed up string match/replace with --max-matches 2024-06-30 17:51:50 -05:00
shorten.rs Tweak the allowed clippy set and fix some 2024-06-30 11:38:15 -07:00
split.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
sub.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
transform.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
trim.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00
unescape.rs Rewrite wgetopt.rs to Rustier syntax and naming 2024-04-17 11:26:51 -07:00