aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2022-11-07 16:53:56 +0100
committerGitHub <noreply@github.com>2022-11-07 16:53:56 +0100
commit652bc83fe45c114440de41d7e0fecf3e4b9e517d (patch)
treea784f0a4b677abc00247638e600f5efef1c44dfc /worktree.go
parent08cffa1efade914020497a73907763e8d3707a77 (diff)
parentffa7e69efb8c4ba8d4e08ec4c65e49e2228fd88b (diff)
downloadgo-git-652bc83fe45c114440de41d7e0fecf3e4b9e517d.tar.gz
Merge pull request #602 from pjbgf/parse-optimisation
Parse optimisations
Diffstat (limited to 'worktree.go')
-rw-r--r--worktree.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/worktree.go b/worktree.go
index c974aed..98116ca 100644
--- a/worktree.go
+++ b/worktree.go
@@ -534,7 +534,8 @@ func (w *Worktree) checkoutChangeRegularFile(name string,
var copyBufferPool = sync.Pool{
New: func() interface{} {
- return make([]byte, 32*1024)
+ b := make([]byte, 32*1024)
+ return &b
},
}
@@ -561,9 +562,10 @@ func (w *Worktree) checkoutFile(f *object.File) (err error) {
}
defer ioutil.CheckClose(to, &err)
- buf := copyBufferPool.Get().([]byte)
+ bufp := copyBufferPool.Get().(*[]byte)
+ buf := *bufp
_, err = io.CopyBuffer(to, from, buf)
- copyBufferPool.Put(buf)
+ copyBufferPool.Put(bufp)
return
}