Skip to content

Commit

Permalink
Merge pull request #139 from yifan-gu/fast_follow
Browse files Browse the repository at this point in the history
sdjournal: Reuse buffer to speed up the Follow().
  • Loading branch information
jonboulle committed Jan 13, 2016
2 parents b9fedff + dde89c2 commit 2ed5b50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sdjournal/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ func (r *JournalReader) Follow(until <-chan time.Time, writer io.Writer) (err er

// Process journal entries and events. Entries are flushed until the tail or
// timeout is reached, and then we wait for new events or the timeout.
var msg = make([]byte, 64*1<<(10))
process:
for {
var msg = make([]byte, 64*1<<(10))

c, err := r.Read(msg)
if err != nil && err != io.EOF {
break process
Expand All @@ -149,7 +148,7 @@ process:
return ErrExpired
default:
if c > 0 {
writer.Write(msg)
writer.Write(msg[:c])
continue process
}
}
Expand Down

0 comments on commit 2ed5b50

Please sign in to comment.