Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit ccf40c5

Browse files
committed
Use buffered IO for decoding index files.
This reduces syscall CPU time from >40% to <10% in my local repository.
1 parent 6b69a16 commit ccf40c5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plumbing/format/idxfile/decoder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package idxfile
22

33
import (
4+
"bufio"
45
"bytes"
56
"errors"
67
"io"
@@ -19,12 +20,12 @@ var (
1920

2021
// Decoder reads and decodes idx files from an input stream.
2122
type Decoder struct {
22-
io.Reader
23+
*bufio.Reader
2324
}
2425

2526
// NewDecoder builds a new idx stream decoder, that reads from r.
2627
func NewDecoder(r io.Reader) *Decoder {
27-
return &Decoder{r}
28+
return &Decoder{bufio.NewReader(r)}
2829
}
2930

3031
// Decode reads from the stream and decode the content into the Idxfile struct.

0 commit comments

Comments
 (0)