Skip to content

Commit

Permalink
Key non pointer opt (#144)
Browse files Browse the repository at this point in the history
* changed to non-pointer with key

* changed cgosymbolizer

* deleted unnecessary line

* replaced all just with parent check for txn

---------

Co-authored-by: Ilya Miheev <[email protected]>
Co-authored-by: alex.sharov <[email protected]>
  • Loading branch information
3 people authored Jun 13, 2024
1 parent 39eccf6 commit e921652
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions mdbx/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e921652

Please sign in to comment.