]> Cypherpunks repositories - gostls13.git/commitdiff
regexp: Remove duplicated function wordRune()
authorSylvain Zimmer <sylvain@sylvainzimmer.com>
Sat, 2 Sep 2017 15:38:45 +0000 (17:38 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 8 Sep 2017 23:39:37 +0000 (23:39 +0000)
Fixes #21742

Change-Id: Ib56b092c490c27a4ba7ebdb6391f1511794710b8
Reviewed-on: https://go-review.googlesource.com/61034
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/regexp/syntax/prog.go

index c32ae8d9fac7d44a369a9e25e14a764d735ea76f..6c56371b4c9a28e909f863f71ee040a228555ad2 100644 (file)
@@ -247,15 +247,6 @@ func (i *Inst) MatchRunePos(r rune) int {
        return noMatch
 }
 
-// As per re2's Prog::IsWordChar. Determines whether rune is an ASCII word char.
-// Since we act on runes, it would be easy to support Unicode here.
-func wordRune(r rune) bool {
-       return r == '_' ||
-               ('A' <= r && r <= 'Z') ||
-               ('a' <= r && r <= 'z') ||
-               ('0' <= r && r <= '9')
-}
-
 // MatchEmptyWidth reports whether the instruction matches
 // an empty string between the runes before and after.
 // It should only be called when i.Op == InstEmptyWidth.
@@ -270,9 +261,9 @@ func (i *Inst) MatchEmptyWidth(before rune, after rune) bool {
        case EmptyEndText:
                return after == -1
        case EmptyWordBoundary:
-               return wordRune(before) != wordRune(after)
+               return IsWordChar(before) != IsWordChar(after)
        case EmptyNoWordBoundary:
-               return wordRune(before) == wordRune(after)
+               return IsWordChar(before) == IsWordChar(after)
        }
        panic("unknown empty width arg")
 }