From 9d4279fd355c1777e0884075f9e64576ddea1a76 Mon Sep 17 00:00:00 2001 From: Arran Walker Date: Sun, 21 Apr 2019 01:22:07 +0000 Subject: plumbing: packfile/scanner, readability/performance improvements, zlib pooling Signed-off-by: Arran Walker --- plumbing/format/packfile/common.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plumbing/format/packfile/common.go') 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 + }, +} -- cgit