summaryrefslogtreecommitdiffstats
path: root/src/matcher.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-02-26 01:42:15 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-02-26 01:42:15 +0900
commitc1aa5c5f3380315621d30d99b258667775b0fad3 (patch)
tree5bfbff2ba5ad7ce1cb8d914106a91bf2cc2939e7 /src/matcher.go
parent4a1752d3fc7f069b0f8afb12ed625acb6fd2aee2 (diff)
Add --tac option and reverse display order of --no-sort
DISCLAIMER: This is a backward incompatible change
Diffstat (limited to 'src/matcher.go')
-rw-r--r--src/matcher.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/matcher.go b/src/matcher.go
index bfe9d287..0879a088 100644
--- a/src/matcher.go
+++ b/src/matcher.go
@@ -21,6 +21,7 @@ type MatchRequest struct {
type Matcher struct {
patternBuilder func([]rune) *Pattern
sort bool
+ tac bool
eventBox *util.EventBox
reqBox *util.EventBox
partitions int
@@ -38,10 +39,11 @@ const (
// NewMatcher returns a new Matcher
func NewMatcher(patternBuilder func([]rune) *Pattern,
- sort bool, eventBox *util.EventBox) *Matcher {
+ sort bool, tac bool, eventBox *util.EventBox) *Matcher {
return &Matcher{
patternBuilder: patternBuilder,
sort: sort,
+ tac: tac,
eventBox: eventBox,
reqBox: util.NewEventBox(),
partitions: runtime.NumCPU(),
@@ -159,7 +161,11 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
countChan <- len(matches)
}
if !empty && m.sort {
- sort.Sort(ByRelevance(sliceMatches))
+ if m.tac {
+ sort.Sort(ByRelevanceTac(sliceMatches))
+ } else {
+ sort.Sort(ByRelevance(sliceMatches))
+ }
}
resultChan <- partialResult{idx, sliceMatches}
}(idx, chunks)
@@ -195,7 +201,7 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
partialResult := <-resultChan
partialResults[partialResult.index] = partialResult.matches
}
- return NewMerger(partialResults, !empty && m.sort), false
+ return NewMerger(partialResults, !empty && m.sort, m.tac), false
}
// Reset is called to interrupt/signal the ongoing search