aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.go
diff options
context:
space:
mode:
Diffstat (limited to 'worktree.go')
-rw-r--r--worktree.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/worktree.go b/worktree.go
index 98116ca..02f90a9 100644
--- a/worktree.go
+++ b/worktree.go
@@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
"strings"
- "sync"
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/util"
@@ -22,6 +21,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/storer"
"github.com/go-git/go-git/v5/utils/ioutil"
"github.com/go-git/go-git/v5/utils/merkletrie"
+ "github.com/go-git/go-git/v5/utils/sync"
)
var (
@@ -532,13 +532,6 @@ func (w *Worktree) checkoutChangeRegularFile(name string,
return nil
}
-var copyBufferPool = sync.Pool{
- New: func() interface{} {
- b := make([]byte, 32*1024)
- return &b
- },
-}
-
func (w *Worktree) checkoutFile(f *object.File) (err error) {
mode, err := f.Mode.ToOSFileMode()
if err != nil {
@@ -562,10 +555,9 @@ func (w *Worktree) checkoutFile(f *object.File) (err error) {
}
defer ioutil.CheckClose(to, &err)
- bufp := copyBufferPool.Get().(*[]byte)
- buf := *bufp
- _, err = io.CopyBuffer(to, from, buf)
- copyBufferPool.Put(bufp)
+ buf := sync.GetByteSlice()
+ _, err = io.CopyBuffer(to, from, *buf)
+ sync.PutByteSlice(buf)
return
}