From 87874bba88c315b11ce5da37c178e6fdedb8708a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 20 Aug 2017 01:58:51 +0900 Subject: [PATCH] Remove redundant read event when --sync is used --- src/core.go | 4 ++++ src/util/eventbox.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/core.go b/src/core.go index 6bb4b2e..1c8182e 100644 --- a/src/core.go +++ b/src/core.go @@ -188,6 +188,7 @@ func Run(opts *Options, revision string) { if opts.Sync { eventBox.Unwatch(EvtReadNew) eventBox.WaitFor(EvtReadFin) + eventBox.Unset(EvtReadNew) } // Go interactive @@ -216,6 +217,9 @@ func Run(opts *Options, revision string) { reading = reading && evt == EvtReadNew snapshot, count := chunkList.Snapshot() terminal.UpdateCount(count, !reading, value.(bool)) + if opts.Sync { + terminal.UpdateList(PassMerger(&snapshot, opts.Tac)) + } matcher.Reset(snapshot, terminal.Input(), false, !reading, sort) case EvtSearchNew: diff --git a/src/util/eventbox.go b/src/util/eventbox.go index b710cf1..acd9561 100644 --- a/src/util/eventbox.go +++ b/src/util/eventbox.go @@ -45,6 +45,13 @@ func (b *EventBox) Set(event EventType, value interface{}) { b.cond.L.Unlock() } +// Unset turns off the event type on the box +func (b *EventBox) Unset(event EventType) { + b.cond.L.Lock() + delete(b.events, event) + b.cond.L.Unlock() +} + // Clear clears the events // Unsynchronized; should be called within Wait routine func (events *Events) Clear() {