seq fallback speedup

Using `string match` instead of `grep -E` resulted in a 2x-3x speedup according
to $CMD_DURATION.
This commit is contained in:
Aaron Gyes 2017-09-22 00:30:26 -07:00
parent fa9e445342
commit 25d83ed0d7

View file

@ -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