aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/common.go
diff options
context:
space:
mode:
authorArran Walker <arran.walker@fiveturns.org>2019-04-21 01:22:07 +0000
committerArran Walker <arran.walker@fiveturns.org>2019-04-22 21:34:09 +0000
commit9d4279fd355c1777e0884075f9e64576ddea1a76 (patch)
treebecbde840864314759bcfa3229496ccf8e0c71e4 /plumbing/format/packfile/common.go
parente5268e9c3c94f60e3c2008dc2ab4762c75352bfc (diff)
downloadgo-git-9d4279fd355c1777e0884075f9e64576ddea1a76.tar.gz
plumbing: packfile/scanner, readability/performance improvements, zlib pooling
Signed-off-by: Arran Walker <arran.walker@fiveturns.org>
Diffstat (limited to 'plumbing/format/packfile/common.go')
-rw-r--r--plumbing/format/packfile/common.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/plumbing/format/packfile/common.go b/plumbing/format/packfile/common.go
index 0d9ed54..f82c1ab 100644
--- a/plumbing/format/packfile/common.go
+++ b/plumbing/format/packfile/common.go
@@ -2,6 +2,7 @@ package packfile
import (
"bytes"
+ "compress/zlib"
"io"
"sync"
@@ -66,3 +67,12 @@ var bufPool = sync.Pool{
return bytes.NewBuffer(nil)
},
}
+
+var zlibInitBytes = []byte{0x78, 0x9c, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01}
+
+var zlibReaderPool = sync.Pool{
+ New: func() interface{} {
+ r, _ := zlib.NewReader(bytes.NewReader(zlibInitBytes))
+ return r
+ },
+}