aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vm.go
diff options
context:
space:
mode:
Diffstat (limited to 'vm/vm.go')
-rw-r--r--vm/vm.go14
1 files changed, 3 insertions, 11 deletions
diff --git a/vm/vm.go b/vm/vm.go
index 7d580e837..522cf5aa8 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -445,9 +445,7 @@ func (mon *monitor) appendOutput(out []byte) (*report.Report, bool) {
}
mon.matchPos--
}
- if mon.matchPos < 0 {
- mon.matchPos = 0
- }
+ mon.matchPos = max(mon.matchPos, 0)
return nil, false
}
@@ -510,14 +508,8 @@ func (mon *monitor) createReport(defaultError string) *report.Report {
Type: typ,
}
}
- start := rep.StartPos - mon.beforeContext
- if start < 0 {
- start = 0
- }
- end := rep.EndPos + afterContext
- if end > len(rep.Output) {
- end = len(rep.Output)
- }
+ start := max(rep.StartPos-mon.beforeContext, 0)
+ end := min(rep.EndPos+afterContext, len(rep.Output))
rep.Output = rep.Output[start:end]
rep.StartPos -= start
rep.EndPos -= start