This commit is contained in:
gobwas 2016-02-22 22:24:05 +03:00
parent bff71ed368
commit 35629e8ad6
2 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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