mdbx: косметический рефакторинг cursor_shadow().

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-03-06 10:27:34 +03:00
parent b0665f7016
commit 436998ca83
2 changed files with 10 additions and 10 deletions

View File

@ -184,12 +184,12 @@ __hot int cursor_touch(MDBX_cursor *const mc, const MDBX_val *key, const MDBX_va
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
int cursor_shadow(MDBX_cursor *cursor, MDBX_txn *nested_txn, const size_t dbi) { int cursor_shadow(MDBX_cursor *cursor, MDBX_txn *nested, const size_t dbi) {
tASSERT(nested_txn, cursor->signature == cur_signature_live); tASSERT(nested, cursor->signature == cur_signature_live);
tASSERT(nested_txn, cursor->txn != nested_txn); tASSERT(nested, cursor->txn != nested);
cASSERT(cursor, cursor->txn->flags & txn_may_have_cursors); cASSERT(cursor, cursor->txn->flags & txn_may_have_cursors);
cASSERT(cursor, dbi == cursor_dbi(cursor)); cASSERT(cursor, dbi == cursor_dbi(cursor));
tASSERT(nested_txn, dbi > FREE_DBI && dbi < nested_txn->n_dbi); tASSERT(nested, dbi > FREE_DBI && dbi < nested->n_dbi);
const size_t size = cursor->subcur ? sizeof(MDBX_cursor) + sizeof(subcur_t) : sizeof(MDBX_cursor); const size_t size = cursor->subcur ? sizeof(MDBX_cursor) + sizeof(subcur_t) : sizeof(MDBX_cursor);
MDBX_cursor *const shadow = osal_malloc(size); MDBX_cursor *const shadow = osal_malloc(size);
@ -202,14 +202,14 @@ int cursor_shadow(MDBX_cursor *cursor, MDBX_txn *nested_txn, const size_t dbi) {
#endif /* MDBX_DEBUG */ #endif /* MDBX_DEBUG */
*shadow = *cursor; *shadow = *cursor;
cursor->backup = shadow; cursor->backup = shadow;
cursor->txn = nested_txn; cursor->txn = nested;
cursor->tree = &nested_txn->dbs[dbi]; cursor->tree = &nested->dbs[dbi];
cursor->dbi_state = &nested_txn->dbi_state[dbi]; cursor->dbi_state = &nested->dbi_state[dbi];
subcur_t *subcur = cursor->subcur; subcur_t *subcur = cursor->subcur;
if (subcur) { if (subcur) {
*(subcur_t *)(shadow + 1) = *subcur; *(subcur_t *)(shadow + 1) = *subcur;
subcur->cursor.txn = nested_txn; subcur->cursor.txn = nested;
subcur->cursor.dbi_state = cursor->dbi_state; subcur->cursor.dbi_state = &nested->dbi_state[dbi];
} }
return MDBX_SUCCESS; return MDBX_SUCCESS;
} }

View File

@ -293,7 +293,7 @@ MDBX_NOTHROW_PURE_FUNCTION static inline bool check_leaf_type(const MDBX_cursor
} }
MDBX_INTERNAL void cursor_eot(MDBX_cursor *cursor); MDBX_INTERNAL void cursor_eot(MDBX_cursor *cursor);
MDBX_INTERNAL int cursor_shadow(MDBX_cursor *cursor, MDBX_txn *nested_txn, const size_t dbi); MDBX_INTERNAL int cursor_shadow(MDBX_cursor *cursor, MDBX_txn *nested, const size_t dbi);
MDBX_INTERNAL MDBX_cursor *cursor_cpstk(const MDBX_cursor *csrc, MDBX_cursor *cdst); MDBX_INTERNAL MDBX_cursor *cursor_cpstk(const MDBX_cursor *csrc, MDBX_cursor *cdst);