forked from mirror/glob
debug info
This commit is contained in:
parent
61a66d485f
commit
6b71a60e74
|
@ -1,6 +1,8 @@
|
|||
package glob
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gobwas/glob/match"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
@ -150,6 +152,13 @@ func TestGlob(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestAllGlobMatch(t *testing.T) {
|
||||
|
||||
m, _ := Compile(pattern_all)
|
||||
fmt.Println("HI", m.(match.Matcher).String())
|
||||
m.Match(fixture_all_match)
|
||||
}
|
||||
|
||||
func BenchmarkParseGlob(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
Compile(pattern_all)
|
||||
|
|
|
@ -77,10 +77,12 @@ func (self BTree) Match(s string) bool {
|
|||
limit = inputLen
|
||||
}
|
||||
|
||||
fmt.Println("ACQUIRE")
|
||||
in := acquireSegments(inputLen)
|
||||
|
||||
for offset < limit {
|
||||
// search for matching part in substring
|
||||
in := acquireSegments(limit - offset)
|
||||
index, segments := self.Value.Index(s[offset:limit], in)
|
||||
index, segments := self.Value.Index(s[offset:limit], in[:0])
|
||||
if index == -1 {
|
||||
releaseSegments(in)
|
||||
return false
|
||||
|
@ -120,12 +122,12 @@ func (self BTree) Match(s string) bool {
|
|||
}
|
||||
}
|
||||
|
||||
releaseSegments(in)
|
||||
|
||||
_, step := utf8.DecodeRuneInString(s[offset+index:])
|
||||
offset += index + step
|
||||
}
|
||||
|
||||
releaseSegments(in)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ func init() {
|
|||
func(i int) {
|
||||
segmentsPools[i-1] = sync.Pool{
|
||||
New: func() interface{} {
|
||||
fmt.Println("NEW", i)
|
||||
return make([]int, 0, i)
|
||||
},
|
||||
}
|
||||
|
@ -74,12 +75,12 @@ func getIdx(c int) int {
|
|||
}
|
||||
|
||||
func acquireSegments(c int) []int {
|
||||
// fmt.Println("GET", getIdx(c))
|
||||
fmt.Println("GET", getIdx(c))
|
||||
return segmentsPools[getIdx(c)].Get().([]int)[:0]
|
||||
}
|
||||
|
||||
func releaseSegments(s []int) {
|
||||
// fmt.Println("PUT", getIdx(cap(s)))
|
||||
fmt.Println("PUT", getIdx(cap(s)))
|
||||
segmentsPools[getIdx(cap(s))].Put(s)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue