Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No pointer optimisation get replacement #141

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions mdbx/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ const (
//
// See MDBX_txn.
type Txn struct {
env *Env
_txn *C.MDBX_txn
key *C.MDBX_val
val *C.MDBX_val
env *Env
_txn *C.MDBX_txn
key *C.MDBX_val
valNP C.MDBX_val
val *C.MDBX_val

errLogf func(format string, v ...interface{})

Expand Down Expand Up @@ -593,15 +594,15 @@ func (txn *Txn) Get(dbi DBI, key []byte) ([]byte, error) {
ret := C.mdbxgo_get(
txn._txn, C.MDBX_dbi(dbi),
k, C.size_t(len(key)),
txn.val,
&txn.valNP,
)
err := operrno("mdbx_get", ret)
if err != nil {
*txn.val = C.MDBX_val{}
txn.valNP.iov_base, txn.valNP.iov_len = nil, 0
return nil, err
}
b := castToBytes(txn.val)
*txn.val = C.MDBX_val{}
b := castToBytes(&txn.valNP)
txn.valNP.iov_base, txn.valNP.iov_len = nil, 0
return b, nil
}

Expand Down
Loading