From 25d83ed0d7104a2d95819463f835c5bced1ef864 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Fri, 22 Sep 2017 00:30:26 -0700 Subject: [PATCH] seq fallback speedup Using `string match` instead of `grep -E` resulted in a 2x-3x speedup according to $CMD_DURATION. --- share/functions/seq.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/functions/seq.fish b/share/functions/seq.fish index 316605e9a..74104b81b 100644 --- a/share/functions/seq.fish +++ b/share/functions/seq.fish @@ -1,4 +1,4 @@ -# If seq is not installed, then define a function that invokes __fish_fallback_seq + # If seq is not installed, then define a function that invokes __fish_fallback_seq # We can't call type here because that also calls seq if not command -sq seq @@ -33,7 +33,7 @@ if not command -sq seq end for i in $from $step $to - if not echo $i | grep -E '^-?[0-9]*([0-9]*|\.[0-9]+)$' >/dev/null + if not string match -rq '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i printf (_ "%s: '%s' is not a number\n") seq $i return 1 end