@@ -408,17 +408,17 @@ func (re *Regexp) LiteralPrefix() (prefix string, complete bool) {
408
408
// MatchReader reports whether the Regexp matches the text read by the
409
409
// RuneReader.
410
410
func (re * Regexp ) MatchReader (r io.RuneReader ) bool {
411
- return re .doExecute (r , nil , "" , 0 , 0 ) != nil
411
+ return re .doMatch (r , nil , "" )
412
412
}
413
413
414
414
// MatchString reports whether the Regexp matches the string s.
415
415
func (re * Regexp ) MatchString (s string ) bool {
416
- return re .doExecute (nil , nil , s , 0 , 0 ) != nil
416
+ return re .doMatch (nil , nil , s )
417
417
}
418
418
419
419
// Match reports whether the Regexp matches the byte slice b.
420
420
func (re * Regexp ) Match (b []byte ) bool {
421
- return re .doExecute (nil , b , "" , 0 , 0 ) != nil
421
+ return re .doMatch (nil , b , "" )
422
422
}
423
423
424
424
// MatchReader checks whether a textual regular expression matches the text
@@ -502,8 +502,9 @@ func (re *Regexp) replaceAll(bsrc []byte, src string, nmatch int, repl func(dst
502
502
nmatch = re .prog .NumCap
503
503
}
504
504
505
+ var dstCap [2 ]int
505
506
for searchPos <= endPos {
506
- a := re .doExecute (nil , bsrc , src , searchPos , nmatch )
507
+ a := re .doExecute (nil , bsrc , src , searchPos , nmatch , dstCap [: 0 ] )
507
508
if len (a ) == 0 {
508
509
break // no more matches
509
510
}
@@ -641,7 +642,7 @@ func (re *Regexp) allMatches(s string, b []byte, n int, deliver func([]int)) {
641
642
}
642
643
643
644
for pos , i , prevMatchEnd := 0 , 0 , - 1 ; i < n && pos <= end ; {
644
- matches := re .doExecute (nil , b , s , pos , re .prog .NumCap )
645
+ matches := re .doExecute (nil , b , s , pos , re .prog .NumCap , nil )
645
646
if len (matches ) == 0 {
646
647
break
647
648
}
@@ -681,7 +682,8 @@ func (re *Regexp) allMatches(s string, b []byte, n int, deliver func([]int)) {
681
682
// Find returns a slice holding the text of the leftmost match in b of the regular expression.
682
683
// A return value of nil indicates no match.
683
684
func (re * Regexp ) Find (b []byte ) []byte {
684
- a := re .doExecute (nil , b , "" , 0 , 2 )
685
+ var dstCap [2 ]int
686
+ a := re .doExecute (nil , b , "" , 0 , 2 , dstCap [:0 ])
685
687
if a == nil {
686
688
return nil
687
689
}
@@ -693,7 +695,7 @@ func (re *Regexp) Find(b []byte) []byte {
693
695
// b[loc[0]:loc[1]].
694
696
// A return value of nil indicates no match.
695
697
func (re * Regexp ) FindIndex (b []byte ) (loc []int ) {
696
- a := re .doExecute (nil , b , "" , 0 , 2 )
698
+ a := re .doExecute (nil , b , "" , 0 , 2 , nil )
697
699
if a == nil {
698
700
return nil
699
701
}
@@ -706,7 +708,8 @@ func (re *Regexp) FindIndex(b []byte) (loc []int) {
706
708
// an empty string. Use FindStringIndex or FindStringSubmatch if it is
707
709
// necessary to distinguish these cases.
708
710
func (re * Regexp ) FindString (s string ) string {
709
- a := re .doExecute (nil , nil , s , 0 , 2 )
711
+ var dstCap [2 ]int
712
+ a := re .doExecute (nil , nil , s , 0 , 2 , dstCap [:0 ])
710
713
if a == nil {
711
714
return ""
712
715
}
@@ -718,7 +721,7 @@ func (re *Regexp) FindString(s string) string {
718
721
// itself is at s[loc[0]:loc[1]].
719
722
// A return value of nil indicates no match.
720
723
func (re * Regexp ) FindStringIndex (s string ) (loc []int ) {
721
- a := re .doExecute (nil , nil , s , 0 , 2 )
724
+ a := re .doExecute (nil , nil , s , 0 , 2 , nil )
722
725
if a == nil {
723
726
return nil
724
727
}
@@ -731,7 +734,7 @@ func (re *Regexp) FindStringIndex(s string) (loc []int) {
731
734
// byte offset loc[0] through loc[1]-1.
732
735
// A return value of nil indicates no match.
733
736
func (re * Regexp ) FindReaderIndex (r io.RuneReader ) (loc []int ) {
734
- a := re .doExecute (r , nil , "" , 0 , 2 )
737
+ a := re .doExecute (r , nil , "" , 0 , 2 , nil )
735
738
if a == nil {
736
739
return nil
737
740
}
@@ -744,7 +747,8 @@ func (re *Regexp) FindReaderIndex(r io.RuneReader) (loc []int) {
744
747
// comment.
745
748
// A return value of nil indicates no match.
746
749
func (re * Regexp ) FindSubmatch (b []byte ) [][]byte {
747
- a := re .doExecute (nil , b , "" , 0 , re .prog .NumCap )
750
+ var dstCap [4 ]int
751
+ a := re .doExecute (nil , b , "" , 0 , re .prog .NumCap , dstCap [:0 ])
748
752
if a == nil {
749
753
return nil
750
754
}
@@ -891,7 +895,7 @@ func extract(str string) (name string, num int, rest string, ok bool) {
891
895
// in the package comment.
892
896
// A return value of nil indicates no match.
893
897
func (re * Regexp ) FindSubmatchIndex (b []byte ) []int {
894
- return re .pad (re .doExecute (nil , b , "" , 0 , re .prog .NumCap ))
898
+ return re .pad (re .doExecute (nil , b , "" , 0 , re .prog .NumCap , nil ))
895
899
}
896
900
897
901
// FindStringSubmatch returns a slice of strings holding the text of the
@@ -900,7 +904,8 @@ func (re *Regexp) FindSubmatchIndex(b []byte) []int {
900
904
// package comment.
901
905
// A return value of nil indicates no match.
902
906
func (re * Regexp ) FindStringSubmatch (s string ) []string {
903
- a := re .doExecute (nil , nil , s , 0 , re .prog .NumCap )
907
+ var dstCap [4 ]int
908
+ a := re .doExecute (nil , nil , s , 0 , re .prog .NumCap , dstCap [:0 ])
904
909
if a == nil {
905
910
return nil
906
911
}
@@ -919,7 +924,7 @@ func (re *Regexp) FindStringSubmatch(s string) []string {
919
924
// 'Index' descriptions in the package comment.
920
925
// A return value of nil indicates no match.
921
926
func (re * Regexp ) FindStringSubmatchIndex (s string ) []int {
922
- return re .pad (re .doExecute (nil , nil , s , 0 , re .prog .NumCap ))
927
+ return re .pad (re .doExecute (nil , nil , s , 0 , re .prog .NumCap , nil ))
923
928
}
924
929
925
930
// FindReaderSubmatchIndex returns a slice holding the index pairs
@@ -928,7 +933,7 @@ func (re *Regexp) FindStringSubmatchIndex(s string) []int {
928
933
// by the 'Submatch' and 'Index' descriptions in the package comment. A
929
934
// return value of nil indicates no match.
930
935
func (re * Regexp ) FindReaderSubmatchIndex (r io.RuneReader ) []int {
931
- return re .pad (re .doExecute (r , nil , "" , 0 , re .prog .NumCap ))
936
+ return re .pad (re .doExecute (r , nil , "" , 0 , re .prog .NumCap , nil ))
932
937
}
933
938
934
939
const startSize = 10 // The size at which to start a slice in the 'All' routines.
0 commit comments