Switch to bare vars in our math invocations

Using bare vars is more efficient because it makes the builtin `math`
expression cache more useful. That's because if you prefix each var with
a dollar-sign then the fish parser expands it before `math` is run.
Something like `math x + 1` can be cached since the expression is the
same each time it is run. But if you do `math $x + 1` and x==1 then you're
effectively executing `math 1 + 1`. And if x==2 the next time then you're
running `math 2 + 1`. Which makes the expression cache much less effective.
This commit is contained in:
Kurtis Rader
2017-08-24 12:38:10 -07:00
parent 56d9134534
commit bd18736ee5
12 changed files with 37 additions and 23 deletions

View File

@@ -23,7 +23,7 @@ function contains_seq --description 'Return true if array contains a sequence'
end
if test "$s" = "$pattern[$i]"
set -e nomatch[1]
set i (math $i + 1)
set i (math i + 1)
if not set -q pattern[$i]
if set -q printnext[1]
set printnext[2] 1