aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-01-26 07:21:32 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-01-26 07:21:32 +0100
commitf39e08f31be9df1620b751e93ed84c87de2b4e86 (patch)
treea53c5a95f3eb35958e3aeff7f778cdaf6a414088
parent050fb78d77b30014acd0b6eefc88ec8a49c20371 (diff)
parent3db12e2e2f550ade9670efbe2ad72608845bb88e (diff)
downloadgo-git-f39e08f31be9df1620b751e93ed84c87de2b4e86.tar.gz
Merge pull request #16 from alcortesm/speedup-packfile-reading
Speed up packfile reading
-rw-r--r--formats/packfile/common.go7
-rw-r--r--formats/packfile/reader.go2
2 files changed, 8 insertions, 1 deletions
diff --git a/formats/packfile/common.go b/formats/packfile/common.go
index 06c63d4..57bc0b9 100644
--- a/formats/packfile/common.go
+++ b/formats/packfile/common.go
@@ -1,6 +1,7 @@
package packfile
import (
+ "bufio"
"fmt"
"io"
)
@@ -10,6 +11,12 @@ type trackingReader struct {
position int64
}
+func NewTrackingReader(r io.Reader) *trackingReader {
+ return &trackingReader{
+ r: bufio.NewReader(r),
+ }
+}
+
func (t *trackingReader) Read(p []byte) (n int, err error) {
n, err = t.r.Read(p)
if err != nil {
diff --git a/formats/packfile/reader.go b/formats/packfile/reader.go
index 3ff342f..37918b1 100644
--- a/formats/packfile/reader.go
+++ b/formats/packfile/reader.go
@@ -59,7 +59,7 @@ func NewReader(r io.Reader) *Reader {
return &Reader{
MaxObjectsLimit: DefaultMaxObjectsLimit,
- r: &trackingReader{r: r},
+ r: NewTrackingReader(r),
offsets: make(map[int64]core.Hash, 0),
}
}