]> Cypherpunks repositories - gostls13.git/commitdiff
regexp: use input.step() to advance one rune in Regexp.allMatches()
authorAndy Pan <panjf2000@gmail.com>
Thu, 28 Oct 2021 07:39:11 +0000 (15:39 +0800)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Sun, 27 Mar 2022 20:22:06 +0000 (20:22 +0000)
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>

src/regexp/regexp.go

index 7d56bd6b8ebca5be3f932920138b934edf319893..26ac5f48b230be0d9f72ab2e7165765ca7b83de2 100644 (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