summaryrefslogtreecommitdiffstats
path: root/src/matcher.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-07-18 03:10:49 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-07-18 03:14:33 +0900
commitbbe10f4f7745000c121b629ff68e81bba5a497f6 (patch)
treef166d6e6d649763db438407ddc7a749d237df11e /src/matcher.go
parent5e72709613b816531c1e0aed6a710257e08bb5d8 (diff)
Consolidate Result and rank structs
By not storing item index twice, we can cut down the size of Result struct and now it makes more sense to store and pass Results by values. Benchmarks show no degradation of performance by additional pointer indirection for looking up index.
Diffstat (limited to 'src/matcher.go')
-rw-r--r--src/matcher.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/matcher.go b/src/matcher.go
index 57c263ab..c29f2b6d 100644
--- a/src/matcher.go
+++ b/src/matcher.go
@@ -131,7 +131,7 @@ func (m *Matcher) sliceChunks(chunks []*Chunk) [][]*Chunk {
type partialResult struct {
index int
- matches []*Result
+ matches []Result
}
func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
@@ -162,7 +162,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
go func(idx int, slab *util.Slab, chunks []*Chunk) {
defer func() { waitGroup.Done() }()
count := 0
- allMatches := make([][]*Result, len(chunks))
+ allMatches := make([][]Result, len(chunks))
for idx, chunk := range chunks {
matches := request.pattern.Match(chunk, slab)
allMatches[idx] = matches
@@ -172,7 +172,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
}
countChan <- len(matches)
}
- sliceMatches := make([]*Result, 0, count)
+ sliceMatches := make([]Result, 0, count)
for _, matches := range allMatches {
sliceMatches = append(sliceMatches, matches...)
}
@@ -212,7 +212,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
}
}
- partialResults := make([][]*Result, numSlices)
+ partialResults := make([][]Result, numSlices)
for _ = range slices {
partialResult := <-resultChan
partialResults[partialResult.index] = partialResult.matches