From 737837c9d45946e6a43f4de5fe3309b9e06ba83f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Thu, 28 Oct 2021 15:39:11 +0800 Subject: [PATCH] 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 Trust: Emmanuel Odeke Run-TryBot: Emmanuel Odeke TryBot-Result: Gopher Robot --- src/regexp/regexp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/regexp/regexp.go b/src/regexp/regexp.go index 7d56bd6b8e..26ac5f48b2 100644 --- a/src/regexp/regexp.go +++ b/src/regexp/regexp.go @@ -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 -- 2.50.0