diff options
author | Julien Dessaux | 2021-10-06 00:08:14 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-06 00:08:14 +0200 |
commit | 2623e80a937a7d0e077a3681e13883778d1032b5 (patch) | |
tree | 384d94e02dd068b716ac14fbd56cc613b4950733 /pkg/pointer/exec.go | |
parent | Improved a test case (diff) | |
download | gofunge98-2623e80a937a7d0e077a3681e13883778d1032b5.tar.gz gofunge98-2623e80a937a7d0e077a3681e13883778d1032b5.tar.bz2 gofunge98-2623e80a937a7d0e077a3681e13883778d1032b5.zip |
Simplified some code
Diffstat (limited to '')
-rw-r--r-- | pkg/pointer/exec.go | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/pkg/pointer/exec.go b/pkg/pointer/exec.go index 2a0776d..9859360 100644 --- a/pkg/pointer/exec.go +++ b/pkg/pointer/exec.go @@ -21,7 +21,6 @@ func (p *Pointer) Exec(f *field.Field) (done bool, returnValue *int) { } if c == '"' { p.stringMode = false - p.lastCharWasSpace = false } else { if c == ' ' { p.lastCharWasSpace = true @@ -65,27 +64,19 @@ func (p *Pointer) eval(c int, f *field.Field) (done bool, returnValue *int) { v := p.ss.head.Pop() return true, &v case 'k': + x, y := p.x, p.y n := p.ss.head.Pop() c = p.StepAndGet(*f) - steps := 1 for jumpingMode := false; jumpingMode || c == ' ' || c == ';'; c = p.StepAndGet(*f) { - steps += 1 if c == ';' { jumpingMode = !jumpingMode } } if n > 0 { - // we need to reverse that step - p.Reverse() - for i := 0; i < steps; i++ { - p.Step(*f) - } - p.Reverse() + p.x, p.y = x, y if c != ' ' && c != ';' { - if n > 0 { - for i := 0; i < n; i++ { - p.eval(c, f) - } + for i := 0; i < n; i++ { + p.eval(c, f) } } } |