aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/common.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-08-14 09:57:46 +0200
committerGitHub <noreply@github.com>2018-08-14 09:57:46 +0200
commita28c2ce44695f13ddf28748958f236afd8e0b544 (patch)
tree107dd441cd96b44b4f3994d26faf5f0bfae933fc /plumbing/format/packfile/common.go
parentc3740924da0d1929cb523c85ae9da3b456b901ea (diff)
parent8d75d239e93474e4287870e4e5143da14e2c360d (diff)
downloadgo-git-a28c2ce44695f13ddf28748958f236afd8e0b544.tar.gz
Merge pull request #906 from src-d/perf/packfile-reads
Improve packfile reading performance
Diffstat (limited to 'plumbing/format/packfile/common.go')
-rw-r--r--plumbing/format/packfile/common.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/plumbing/format/packfile/common.go b/plumbing/format/packfile/common.go
index beb015d..2b4aceb 100644
--- a/plumbing/format/packfile/common.go
+++ b/plumbing/format/packfile/common.go
@@ -23,24 +23,28 @@ const (
maskType = uint8(112) // 0111 0000
)
-// UpdateObjectStorage updates the given storer.EncodedObjectStorer with the contents of the
+// UpdateObjectStorage updates the storer with the objects in the given
// packfile.
-func UpdateObjectStorage(s storer.EncodedObjectStorer, packfile io.Reader) error {
- if sw, ok := s.(storer.PackfileWriter); ok {
- return writePackfileToObjectStorage(sw, packfile)
+func UpdateObjectStorage(s storer.Storer, packfile io.Reader) error {
+ if pw, ok := s.(storer.PackfileWriter); ok {
+ return WritePackfileToObjectStorage(pw, packfile)
}
- stream := NewScanner(packfile)
- d, err := NewDecoder(stream, s)
+ p, err := NewParserWithStorage(NewScanner(packfile), s)
if err != nil {
return err
}
- _, err = d.Decode()
+ _, err = p.Parse()
return err
}
-func writePackfileToObjectStorage(sw storer.PackfileWriter, packfile io.Reader) (err error) {
+// WritePackfileToObjectStorage writes all the packfile objects into the given
+// object storage.
+func WritePackfileToObjectStorage(
+ sw storer.PackfileWriter,
+ packfile io.Reader,
+) (err error) {
w, err := sw.PackfileWriter()
if err != nil {
return err