diff --git a/match/btree.go b/match/btree.go index aa62e59..3e4b001 100644 --- a/match/btree.go +++ b/match/btree.go @@ -83,11 +83,12 @@ 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) + }() + // var segments []int + // segments := make([]int, 0, inputLen) for offset < limit { // search for matching part in substring diff --git a/match/btree_test.go b/match/btree_test.go index dced6e5..7f96410 100644 --- a/match/btree_test.go +++ b/match/btree_test.go @@ -55,8 +55,14 @@ type fakeMatcher struct { func (f *fakeMatcher) Match(string) bool { return true } + +var i = 3 + func (f *fakeMatcher) Index(s string, seg []int) (int, []int) { - return 0, append(seg, 1) + for x := 0; x < i; x++ { + seg = append(seg, x) + } + return 0, seg } func (f *fakeMatcher) Len() int { return f.len