mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-02 10:44:44 +08:00
mdbx: refactor internal walking functions.
This commit is contained in:
parent
d6f397145c
commit
79465dbc7f
13
src/walk.c
13
src/walk.c
@ -3,17 +3,6 @@
|
||||
|
||||
#include "internals.h"
|
||||
|
||||
typedef struct walk_ctx {
|
||||
void *userctx;
|
||||
walk_options_t options;
|
||||
int deep;
|
||||
walk_func *visitor;
|
||||
MDBX_txn *txn;
|
||||
MDBX_cursor *cursor;
|
||||
} walk_ctx_t;
|
||||
|
||||
__cold static int walk_tbl(walk_ctx_t *ctx, walk_tbl_t *tbl);
|
||||
|
||||
static page_type_t walk_page_type(const page_t *mp) {
|
||||
if (mp)
|
||||
switch (mp->flags & ~P_SPILLED) {
|
||||
@ -251,7 +240,7 @@ __cold static int walk_pgno(walk_ctx_t *ctx, walk_tbl_t *tbl, const pgno_t pgno,
|
||||
return MDBX_SUCCESS;
|
||||
}
|
||||
|
||||
__cold static int walk_tbl(walk_ctx_t *ctx, walk_tbl_t *tbl) {
|
||||
__cold int walk_tbl(walk_ctx_t *ctx, walk_tbl_t *tbl) {
|
||||
tree_t *const db = tbl->internal;
|
||||
if (unlikely(db->root == P_INVALID))
|
||||
return MDBX_SUCCESS; /* empty db */
|
||||
|
11
src/walk.h
11
src/walk.h
@ -18,3 +18,14 @@ typedef int walk_func(const size_t pgno, const unsigned number, void *const ctx,
|
||||
typedef enum walk_options { dont_check_keys_ordering = 1 } walk_options_t;
|
||||
|
||||
MDBX_INTERNAL int walk_pages(MDBX_txn *txn, walk_func *visitor, void *user, walk_options_t options);
|
||||
|
||||
typedef struct walk_ctx {
|
||||
void *userctx;
|
||||
walk_options_t options;
|
||||
int deep;
|
||||
walk_func *visitor;
|
||||
MDBX_txn *txn;
|
||||
MDBX_cursor *cursor;
|
||||
} walk_ctx_t;
|
||||
|
||||
MDBX_INTERNAL int walk_tbl(walk_ctx_t *ctx, walk_tbl_t *tbl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user