Commit 762e42f4 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/fs1: Don't avoid defer anymore

Starting from Go1.14 defer is no longer slow:
https://golang.org/doc/go1.14#runtime
parent 049cb9a0
// Copyright (C) 2017-2019 Nexedi SA and Contributors. // Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -182,13 +182,8 @@ func (fs *FileStorage) load(xid zodb.Xid) (buf *mem.Buf, serial zodb.Tid, err er ...@@ -182,13 +182,8 @@ func (fs *FileStorage) load(xid zodb.Xid) (buf *mem.Buf, serial zodb.Tid, err er
dh.Oid = xid.Oid dh.Oid = xid.Oid
dh.Tid = zodb.TidMax dh.Tid = zodb.TidMax
dh.PrevRevPos = dataPos dh.PrevRevPos = dataPos
//defer dh.Free() defer dh.Free()
buf, serial, err = fs._load(dh, xid)
dh.Free()
return buf, serial, err
}
func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid, error) {
// search backwards for when we first have data record with tid satisfying xid.At // search backwards for when we first have data record with tid satisfying xid.At
for { for {
err := dh.LoadPrevRev(fs.file) err := dh.LoadPrevRev(fs.file)
...@@ -208,9 +203,9 @@ func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid, ...@@ -208,9 +203,9 @@ func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid,
// even if we will scan back via backpointers, the serial returned should // even if we will scan back via backpointers, the serial returned should
// be of first-found transaction // be of first-found transaction
serial := dh.Tid serial = dh.Tid
buf, err := dh.LoadData(fs.file) buf, err = dh.LoadData(fs.file)
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment