Commit 5a48e702 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Don't avoid defer

Starting from Go1.14 defer is no longer slow:
https://golang.org/doc/go1.14#runtime
parent 8889743e
......@@ -73,16 +73,13 @@ func (z *zeo) Sync(ctx context.Context) (head zodb.Tid, err error) {
return head, nil
}
func (z *zeo) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, error) {
// defer func() ...
buf, serial, err := z._Load(ctx, xid)
func (z *zeo) Load(ctx context.Context, xid zodb.Xid) (buf *mem.Buf, serial zodb.Tid, err error) {
defer func() {
if err != nil {
err = &zodb.OpError{URL: z.URL(), Op: "load", Args: xid, Err: err}
}
return buf, serial, err
}
}()
func (z *zeo) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, error) {
rpc := z.rpc("loadBefore")
xres, err := rpc.call(ctx, oidPack(xid.Oid), tidPack(xid.At+1)) // XXX at2Before
if err != nil {
......
......@@ -216,16 +216,13 @@ func pktDecode(pkb *pktBuf) (msg, error) {
// Call makes 1 RPC call to server, waits for reply and returns it.
func (zl *zLink) Call(ctx context.Context, method string, argv ...interface{}) (reply msg, _ error) {
// defer func() ...
reply, err := zl._call(ctx, method, argv...)
func (zl *zLink) Call(ctx context.Context, method string, argv ...interface{}) (reply msg, err error) {
defer func() {
if err != nil {
err = fmt.Errorf("%s: call %s: %s", zl.link.RemoteAddr(), method, err)
}
return reply, err
}
}()
func (zl *zLink) _call(ctx context.Context, method string, argv ...interface{}) (reply msg, _ error) {
rxc := make(chan msg, 1) // reply will go here
// register our call
......@@ -242,7 +239,7 @@ func (zl *zLink) _call(ctx context.Context, method string, argv ...interface{})
// (msgid, async, method, argv)
pkb := allocPkb()
p := pickle.NewEncoder(pkb)
err := p.Encode(pickle.Tuple{callID, false, method, pickle.Tuple(argv)})
err = p.Encode(pickle.Tuple{callID, false, method, pickle.Tuple(argv)})
if err != nil {
panic(err) // all our types are expected to be supported by pickle
}
......
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