diff options
author | Nao YONASHIRO <owan.orisano@gmail.com> | 2019-07-25 17:56:22 +0900 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2019-07-25 10:56:22 +0200 |
commit | 8beb3ee82048ec6be5471c7a056b72e89346898a (patch) | |
tree | 77c46a623f6a20cb7d45a26fde62283d192a9895 /storage | |
parent | c363771e002cbdf4dcf8a9cc5f1fefdd5769f5dd (diff) | |
download | go-git-8beb3ee82048ec6be5471c7a056b72e89346898a.tar.gz |
Worktree: improve build index performance. (#1179)
Diffstat (limited to 'storage')
-rw-r--r-- | storage/filesystem/index.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/storage/filesystem/index.go b/storage/filesystem/index.go index d04195c..be800ef 100644 --- a/storage/filesystem/index.go +++ b/storage/filesystem/index.go @@ -20,8 +20,14 @@ func (s *IndexStorage) SetIndex(idx *index.Index) (err error) { } defer ioutil.CheckClose(f, &err) + bw := bufio.NewWriter(f) + defer func() { + if e := bw.Flush(); err == nil && e != nil { + err = e + } + }() - e := index.NewEncoder(f) + e := index.NewEncoder(bw) err = e.Encode(idx) return err } |