From ccf40c5a824cd755025ba58931e58722eddacbcc Mon Sep 17 00:00:00 2001 From: JP Sugarbroad Date: Mon, 10 Jul 2017 15:51:12 -0700 Subject: Use buffered IO for decoding index files. This reduces syscall CPU time from >40% to <10% in my local repository. --- plumbing/format/idxfile/decoder.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plumbing/format/idxfile/decoder.go b/plumbing/format/idxfile/decoder.go index 6618475..fea5f0b 100644 --- a/plumbing/format/idxfile/decoder.go +++ b/plumbing/format/idxfile/decoder.go @@ -1,6 +1,7 @@ package idxfile import ( + "bufio" "bytes" "errors" "io" @@ -19,12 +20,12 @@ var ( // Decoder reads and decodes idx files from an input stream. type Decoder struct { - io.Reader + *bufio.Reader } // NewDecoder builds a new idx stream decoder, that reads from r. func NewDecoder(r io.Reader) *Decoder { - return &Decoder{r} + return &Decoder{bufio.NewReader(r)} } // Decode reads from the stream and decode the content into the Idxfile struct. -- cgit