From b7bb1008107fb079e68f9ebeeca699c65cc966c9 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 10 Jan 2015 01:06:08 +0900 Subject: Improve response time by only looking at top-N items --- src/core.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core.go') diff --git a/src/core.go b/src/core.go index e5bdb129..98973f8b 100644 --- a/src/core.go +++ b/src/core.go @@ -93,17 +93,18 @@ func Run(options *Options) { } snapshot, _ := chunkList.Snapshot() - matches, cancelled := matcher.scan(MatchRequest{ + merger, cancelled := matcher.scan(MatchRequest{ chunks: snapshot, pattern: pattern}, limit) if !cancelled && (filtering || - opts.Exit0 && len(matches) == 0 || opts.Select1 && len(matches) == 1) { + opts.Exit0 && merger.Length() == 0 || + opts.Select1 && merger.Length() == 1) { if opts.PrintQuery { fmt.Println(patternString) } - for _, item := range matches { - item.Print() + for i := 0; i < merger.Length(); i++ { + merger.Get(i).Print() } os.Exit(0) } @@ -147,7 +148,7 @@ func Run(options *Options) { case EVT_SEARCH_FIN: switch val := value.(type) { - case []*Item: + case *Merger: terminal.UpdateList(val) } } -- cgit v1.2.3