diff options
author | Adam Scarr <adam@vektah.net> | 2017-08-13 17:30:10 +1000 |
---|---|---|
committer | Adam Scarr <adam@vektah.net> | 2017-08-13 18:56:23 +1000 |
commit | 5716ddb5e7ca3cb4ee445bdd4958c37aeb033baa (patch) | |
tree | a5d5017dbf1078220ceef24d9ea9432b33972291 /debugon.go | |
parent | 0dc37ae5bc10cc0669f88ab9febbc039a28f23d1 (diff) |
Pass result in instead of returning
Diffstat (limited to 'debugon.go')
-rw-r--r-- | debugon.go | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -53,7 +53,7 @@ func (dp *debugParser) logf(ps *State, result *Result, format string, args ...in buf.WriteString(fmt.Sprintf("%-10s | ", output)) buf.WriteString(strings.Repeat(" ", len(activeParsers)-1)) buf.WriteString(fmt.Sprintf(format, args...)) - + buf.WriteString(fmt.Sprintf(" > %#v", result)) buf.WriteRune('\n') return buf.String() } @@ -77,14 +77,14 @@ func (dp *debugParser) logEnd(ps *State, result *Result) { } } -func (dp *debugParser) Parse(ps *State) Result { +func (dp *debugParser) Parse(ps *State, node *Result) { activeParsers = append(activeParsers, dp) start := time.Now() dp.SelfStart = start dp.logStart(ps) - ret := dp.Next(ps) - dp.logEnd(ps, &ret) + dp.Next(ps, node) + dp.logEnd(ps, node) dp.Cumulative += time.Since(start) dp.Self += time.Since(dp.SelfStart) @@ -94,7 +94,6 @@ func (dp *debugParser) Parse(ps *State) Result { } activeParsers = activeParsers[0 : len(activeParsers)-1] - return ret } // NewParser should be called around the creation of every Parser. @@ -109,13 +108,12 @@ func NewParser(name string, p Parser) Parser { Location: location, } - dp.Next = func(ps *State) Result { + dp.Next = func(ps *State, ret *Result) { dp.Self += time.Since(dp.SelfStart) - ret := p(ps) + p(ps, ret) dp.SelfStart = time.Now() - return ret } if len(dp.Location) > longestLocation { |