Skip to content

Commit cc6d732

Browse files
committed
It appears that nio.Pipe likely does improve things...
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 556badf commit cc6d732

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/git/batch_reader.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import (
1111
"math"
1212
"strconv"
1313
"strings"
14+
15+
"github.com/djherbis/buffer"
16+
"github.com/djherbis/nio/v3"
1417
)
1518

1619
// WriteCloserError wraps an io.WriteCloser with an additional CloseWithError function
@@ -23,7 +26,7 @@ type WriteCloserError interface {
2326
func CatFileBatchCheck(repoPath string) (WriteCloserError, *bufio.Reader, func()) {
2427

2528
batchStdinReader, batchStdinWriter := io.Pipe()
26-
batchStdoutReader, batchStdoutWriter := io.Pipe()
29+
batchStdoutReader, batchStdoutWriter := nio.Pipe(buffer.New(4 * 1024))
2730
cancel := func() {
2831
_ = batchStdinReader.Close()
2932
_ = batchStdinWriter.Close()
@@ -43,7 +46,7 @@ func CatFileBatchCheck(repoPath string) (WriteCloserError, *bufio.Reader, func()
4346
}
4447
}()
4548

46-
// For simplicities sake we'll us a buffered reader to read from the cat-file --batch
49+
// For simplicities sake we'll use a buffered reader to read from the cat-file --batch-check
4750
batchReader := bufio.NewReader(batchStdoutReader)
4851

4952
return batchStdinWriter, batchReader, cancel
@@ -54,7 +57,7 @@ func CatFileBatch(repoPath string) (WriteCloserError, *bufio.Reader, func()) {
5457
// We often want to feed the commits in order into cat-file --batch, followed by their trees and sub trees as necessary.
5558
// so let's create a batch stdin and stdout
5659
batchStdinReader, batchStdinWriter := io.Pipe()
57-
batchStdoutReader, batchStdoutWriter := io.Pipe()
60+
batchStdoutReader, batchStdoutWriter := nio.Pipe(buffer.New(32 * 1024))
5861
cancel := func() {
5962
_ = batchStdinReader.Close()
6063
_ = batchStdinWriter.Close()

0 commit comments

Comments
 (0)