mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[REV] git packfile, avoid allocating in teeReader.ReadByte
This commit is contained in:
parent
7aac3a6106
commit
ca5a1280dc
@ -36,7 +36,7 @@ func TestGitClone(t *testing.T) {
|
||||
Branch: "master",
|
||||
}
|
||||
//logger := event.GetManager().GetLogger("system")
|
||||
res, err := GitClone(csi, "/tmp/rainbonddoc", nil, 1)
|
||||
res, err := GitClone(csi, "/tmp/rainbonddoc2", nil, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
10
vendor/gopkg.in/src-d/go-git.v4/plumbing/format/packfile/scanner.go
generated
vendored
10
vendor/gopkg.in/src-d/go-git.v4/plumbing/format/packfile/scanner.go
generated
vendored
@ -64,8 +64,8 @@ func NewScanner(r io.Reader) *Scanner {
|
||||
crc := crc32.NewIEEE()
|
||||
return &Scanner{
|
||||
r: &teeReader{
|
||||
newByteReadSeeker(seeker),
|
||||
crc,
|
||||
reader: newByteReadSeeker(seeker),
|
||||
w: crc,
|
||||
},
|
||||
crc: crc,
|
||||
IsSeekable: ok,
|
||||
@ -400,7 +400,8 @@ type reader interface {
|
||||
|
||||
type teeReader struct {
|
||||
reader
|
||||
w hash.Hash32
|
||||
w hash.Hash32
|
||||
buf [1]byte
|
||||
}
|
||||
|
||||
func (r *teeReader) Read(p []byte) (n int, err error) {
|
||||
@ -416,7 +417,8 @@ func (r *teeReader) Read(p []byte) (n int, err error) {
|
||||
func (r *teeReader) ReadByte() (b byte, err error) {
|
||||
b, err = r.reader.ReadByte()
|
||||
if err == nil {
|
||||
_, err := r.w.Write([]byte{b})
|
||||
r.buf[0] = b
|
||||
_, err := r.w.Write(r.buf[:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user