forked from mirror/glob
test
This commit is contained in:
parent
ea3a6f712d
commit
88b0fce4f5
|
@ -83,15 +83,15 @@ func (self BTree) Match(s string) bool {
|
|||
|
||||
// reusable segments list
|
||||
// inputLen is the maximum size of output segments values
|
||||
// segments := acquireSegments(inputLen)
|
||||
// defer func() {
|
||||
// releaseSegments(segments)
|
||||
// }()
|
||||
// var segments []int
|
||||
segments := acquireSegments(inputLen)
|
||||
defer func() {
|
||||
releaseSegments(segments)
|
||||
}()
|
||||
// segments := make([]int, 0, 4)
|
||||
|
||||
for offset < limit {
|
||||
// search for matching part in substring
|
||||
index, segments := self.Value.Index(s[offset:limit], nil)
|
||||
index, segments := self.Value.Index(s[offset:limit], segments[:0])
|
||||
if index == -1 {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func (self Range) Index(s string, segments []int) (int, []int) {
|
|||
}
|
||||
}
|
||||
|
||||
return -1, nil
|
||||
return -1, segments
|
||||
}
|
||||
|
||||
func (self Range) String() string {
|
||||
|
|
|
@ -54,7 +54,7 @@ func (self Row) Len() (l int) {
|
|||
|
||||
func (self Row) Index(s string, segments []int) (int, []int) {
|
||||
if !self.lenOk(s) {
|
||||
return -1, nil
|
||||
return -1, segments
|
||||
}
|
||||
|
||||
for i := range s {
|
||||
|
@ -70,7 +70,7 @@ func (self Row) Index(s string, segments []int) (int, []int) {
|
|||
}
|
||||
}
|
||||
|
||||
return -1, nil
|
||||
return -1, segments
|
||||
}
|
||||
|
||||
func (self Row) String() string {
|
||||
|
|
|
@ -20,8 +20,8 @@ func toPowerOfTwo(v int) int {
|
|||
}
|
||||
|
||||
const (
|
||||
minSegment = 32
|
||||
minSegmentMinusOne = 31
|
||||
minSegment = 4
|
||||
minSegmentMinusOne = 3
|
||||
maxSegment = 1024
|
||||
maxSegmentMinusOne = 1023
|
||||
)
|
||||
|
|
|
@ -32,7 +32,7 @@ func (self Text) Len() int {
|
|||
func (self Text) Index(s string, segments []int) (int, []int) {
|
||||
index := strings.Index(s, self.Str)
|
||||
if index == -1 {
|
||||
return -1, nil
|
||||
return -1, segments
|
||||
}
|
||||
|
||||
return index, append(segments, self.BytesLength)
|
||||
|
|
Loading…
Reference in New Issue