diff --git a/src/regexp/exec.go b/src/regexp/exec.go index b8e30b2184ef8c..37daf9dec1e5f5 100644 --- a/src/regexp/exec.go +++ b/src/regexp/exec.go @@ -519,15 +519,15 @@ func (re *Regexp) doMatch(r io.RuneReader, b []byte, s string) bool { // // nil is returned if no matches are found and non-nil if matches are found. func (re *Regexp) find(r io.RuneReader, b []byte, s string, pos int, ncap int, dstCap []int) []int { + if r == nil && len(b)+len(s) < re.minInputLen { + return nil + } + if dstCap == nil { // Make sure 'return dstCap' is non-nil. dstCap = arrayNoInts[:0:0] } - if r == nil && len(b)+len(s) < re.minInputLen { - return nil - } - if re.onepass != nil { return re.doOnePass(r, b, s, pos, ncap, dstCap) }