diff options
author | JP Sugarbroad <jpsugar@google.com> | 2017-07-10 15:51:12 -0700 |
---|---|---|
committer | JP Sugarbroad <jpsugar@google.com> | 2017-07-10 15:51:12 -0700 |
commit | ccf40c5a824cd755025ba58931e58722eddacbcc (patch) | |
tree | 3cd0cc022e2f44f521fd9ef074dab0214b2b8be7 /plumbing | |
parent | 6b69a1630b30c41f4563fd95aca1d647ba611adf (diff) | |
download | go-git-ccf40c5a824cd755025ba58931e58722eddacbcc.tar.gz |
Use buffered IO for decoding index files.
This reduces syscall CPU time from >40% to <10% in my local repository.
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/format/idxfile/decoder.go | 5 |
1 files 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. |