From e9216523a32c4a359dcb388acffcc5b6ba4cce5e Mon Sep 17 00:00:00 2001 From: Ilya Mikheev <54912776+JkLondon@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:55:54 +0400 Subject: [PATCH] Key non pointer opt (#144) * changed to non-pointer with key * changed cgosymbolizer * deleted unnecessary line * replaced all just with parent check for txn --------- Co-authored-by: Ilya Miheev Co-authored-by: alex.sharov --- mdbx/txn.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/mdbx/txn.go b/mdbx/txn.go index 32832a4..1eb0116 100644 --- a/mdbx/txn.go +++ b/mdbx/txn.go @@ -88,24 +88,10 @@ func beginTxn(env *Env, parent *Txn, flags uint) (*Txn, error) { } var ptxn *C.MDBX_txn - if parent == nil { - if flags&Readonly == 0 { - // In a write Txn we can use the shared, C-allocated key and value - // allocated by env, and freed when it is closed. - txn.key = *env.ckey - } else { - // It is not easy to share C.MDBX_val values in this scenario unless - // there is a synchronized pool involved, which will increase - // overhead. Further, allocating these values with C will add - // overhead both here and when the values are freed. - txn.key = C.MDBX_val{} - } - } else { + if parent != nil { // Because parent Txn objects cannot be used while a sub-Txn is active // it is OK for them to share their C.MDBX_val objects. ptxn = parent._txn - txn.key = parent.key - txn.val = parent.val } ret := C.mdbx_txn_begin(env._env, ptxn, C.MDBX_txn_flags_t(flags), &txn._txn) if ret != success {