diff --git a/glob_test.go b/glob_test.go index d0264f6..08de6f7 100644 --- a/glob_test.go +++ b/glob_test.go @@ -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) diff --git a/match/btree.go b/match/btree.go index ad8f5f9..a9a7a15 100644 --- a/match/btree.go +++ b/match/btree.go @@ -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 } diff --git a/match/match.go b/match/match.go index f9dcae1..9df55fd 100644 --- a/match/match.go +++ b/match/match.go @@ -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) }