1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

file: pool index readers to reduce allocs for #122

This commit is contained in:
James Hillyerd
2018-10-20 20:33:27 -07:00
parent 98745b3bb9
commit f68f07d896
2 changed files with 31 additions and 6 deletions

View File

@@ -120,7 +120,9 @@ func (mb *mbox) readIndex() error {
}
}()
// Decode gob data
dec := gob.NewDecoder(bufio.NewReader(file))
br := mb.store.getPooledReader(file)
defer mb.store.putPooledReader(br)
dec := gob.NewDecoder(br)
name := ""
if err = dec.Decode(&name); err != nil {
return fmt.Errorf("Corrupt mailbox %q: %v", mb.indexPath, err)