regexp: use input.step() to advance one rune in Regexp.allMatches()

Change-Id: I32944f4ed519419e168e62f9ed6df63961839259
Reviewed-on: https://go-review.googlesource.com/c/go/+/359197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Andy Pan 2021-10-28 15:39:11 +08:00 committed by Emmanuel Odeke
parent 018b78cc5b
commit 737837c9d4
1 changed files with 4 additions and 3 deletions

View File

@ -793,11 +793,12 @@ func (re *Regexp) allMatches(s string, b []byte, n int, deliver func([]int)) {
accept = false
}
var width int
// TODO: use step()
if b == nil {
_, width = utf8.DecodeRuneInString(s[pos:end])
is := inputString{str: s}
_, width = is.step(pos)
} else {
_, width = utf8.DecodeRune(b[pos:end])
ib := inputBytes{str: b}
_, width = ib.step(pos)
}
if width > 0 {
pos += width