mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: using clang-format-13
(cosmetics).
This commit is contained in:
parent
38df3ca5ad
commit
c2cab7a6a8
@ -298,11 +298,11 @@ else()
|
||||
|
||||
if(UNIX)
|
||||
find_program(CLANG_FORMAT
|
||||
NAMES clang-format-12 clang-format-11 clang-format-10 clang-format)
|
||||
NAMES clang-format-13 clang-format)
|
||||
if(CLANG_FORMAT)
|
||||
execute_process(COMMAND ${CLANG_FORMAT} "--version" OUTPUT_VARIABLE clang_format_version_info)
|
||||
string(REGEX MATCH "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" clang_format_version_info CLANG_FORMAT_VERSION)
|
||||
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 10.0)
|
||||
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 13.0)
|
||||
# Enable 'make reformat' target.
|
||||
add_custom_target(reformat
|
||||
VERBATIM
|
||||
|
25
mdbx.h++
25
mdbx.h++
@ -477,30 +477,23 @@ static MDBX_CXX20_CONSTEXPR void *memcpy(void *dest, const void *src,
|
||||
|
||||
template <typename T>
|
||||
concept MutableByteProducer = requires(T a, char array[42]) {
|
||||
{ a.is_empty() }
|
||||
->std::same_as<bool>;
|
||||
{ a.envisage_result_length() }
|
||||
->std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) }
|
||||
->std::same_as<char *>;
|
||||
{ a.is_empty() } -> std::same_as<bool>;
|
||||
{ a.envisage_result_length() } -> std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) } -> std::same_as<char *>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept ImmutableByteProducer = requires(const T &a, char array[42]) {
|
||||
{ a.is_empty() }
|
||||
->std::same_as<bool>;
|
||||
{ a.envisage_result_length() }
|
||||
->std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) }
|
||||
->std::same_as<char *>;
|
||||
{ a.is_empty() } -> std::same_as<bool>;
|
||||
{ a.envisage_result_length() } -> std::same_as<size_t>;
|
||||
{ a.write_bytes(&array[0], size_t(42)) } -> std::same_as<char *>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept SliceTranscoder =
|
||||
ImmutableByteProducer<T> &&requires(const slice &source, const T &a) {
|
||||
concept SliceTranscoder = ImmutableByteProducer<T> &&
|
||||
requires(const slice &source, const T &a) {
|
||||
T(source);
|
||||
{ a.is_erroneous() }
|
||||
->std::same_as<bool>;
|
||||
{ a.is_erroneous() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
#endif /* __cpp_concepts >= 201907L*/
|
||||
|
45
src/core.c
45
src/core.c
@ -5102,9 +5102,9 @@ static unsigned spill_prio(const MDBX_txn *txn, const unsigned i,
|
||||
MDBX_page *const dp = dl->items[i].ptr;
|
||||
if (dp->mp_flags & (P_LOOSE | P_SPILLED)) {
|
||||
mdbx_debug("skip %s %u page %" PRIaPGNO,
|
||||
(dp->mp_flags & P_LOOSE)
|
||||
? "loose"
|
||||
: (dp->mp_flags & P_LOOSE) ? "loose" : "parent-spilled",
|
||||
(dp->mp_flags & P_LOOSE) ? "loose"
|
||||
: (dp->mp_flags & P_LOOSE) ? "loose"
|
||||
: "parent-spilled",
|
||||
npages, pgno);
|
||||
return 256;
|
||||
}
|
||||
@ -9204,7 +9204,8 @@ retry_noaccount:
|
||||
txn->tw.lifo_reclaimed
|
||||
? (unsigned)MDBX_PNL_SIZE(txn->tw.lifo_reclaimed) -
|
||||
reused_gc_slot + 1
|
||||
: (gc_rid < INT16_MAX) ? (unsigned)gc_rid : INT16_MAX;
|
||||
: (gc_rid < INT16_MAX) ? (unsigned)gc_rid
|
||||
: INT16_MAX;
|
||||
if (avail_gc_slots > 1) {
|
||||
if (chunk < env->me_maxgc_ov1page * 2)
|
||||
chunk /= 2;
|
||||
@ -10443,10 +10444,9 @@ __cold static int mdbx_read_header(MDBX_env *env, MDBX_meta *dest,
|
||||
unsigned guess_pagesize = 0;
|
||||
for (unsigned loop_count = 0; loop_count < loop_limit; ++loop_count) {
|
||||
const unsigned meta_number = loop_count % NUM_METAS;
|
||||
const unsigned offset =
|
||||
(guess_pagesize
|
||||
? guess_pagesize
|
||||
: (loop_count > NUM_METAS) ? env->me_psize : env->me_os_psize) *
|
||||
const unsigned offset = (guess_pagesize ? guess_pagesize
|
||||
: (loop_count > NUM_METAS) ? env->me_psize
|
||||
: env->me_os_psize) *
|
||||
meta_number;
|
||||
|
||||
char buffer[MIN_PAGESIZE];
|
||||
@ -10802,17 +10802,23 @@ static int mdbx_sync_locked(MDBX_env *env, unsigned flags,
|
||||
|
||||
mdbx_debug("meta0: %s, %s, txn_id %" PRIaTXN ", root %" PRIaPGNO
|
||||
"/%" PRIaPGNO,
|
||||
(meta0 == head) ? "head" : (meta0 == target) ? "tail" : "stay",
|
||||
(meta0 == head) ? "head"
|
||||
: (meta0 == target) ? "tail"
|
||||
: "stay",
|
||||
mdbx_durable_str(meta0), mdbx_meta_txnid_fluid(env, meta0),
|
||||
meta0->mm_dbs[MAIN_DBI].md_root, meta0->mm_dbs[FREE_DBI].md_root);
|
||||
mdbx_debug("meta1: %s, %s, txn_id %" PRIaTXN ", root %" PRIaPGNO
|
||||
"/%" PRIaPGNO,
|
||||
(meta1 == head) ? "head" : (meta1 == target) ? "tail" : "stay",
|
||||
(meta1 == head) ? "head"
|
||||
: (meta1 == target) ? "tail"
|
||||
: "stay",
|
||||
mdbx_durable_str(meta1), mdbx_meta_txnid_fluid(env, meta1),
|
||||
meta1->mm_dbs[MAIN_DBI].md_root, meta1->mm_dbs[FREE_DBI].md_root);
|
||||
mdbx_debug("meta2: %s, %s, txn_id %" PRIaTXN ", root %" PRIaPGNO
|
||||
"/%" PRIaPGNO,
|
||||
(meta2 == head) ? "head" : (meta2 == target) ? "tail" : "stay",
|
||||
(meta2 == head) ? "head"
|
||||
: (meta2 == target) ? "tail"
|
||||
: "stay",
|
||||
mdbx_durable_str(meta2), mdbx_meta_txnid_fluid(env, meta2),
|
||||
meta2->mm_dbs[MAIN_DBI].md_root, meta2->mm_dbs[FREE_DBI].md_root);
|
||||
|
||||
@ -10935,10 +10941,13 @@ fail:
|
||||
|
||||
static void recalculate_merge_threshold(MDBX_env *env) {
|
||||
const unsigned bytes = page_space(env);
|
||||
env->me_merge_threshold = (uint16_t)(
|
||||
bytes - (bytes * env->me_options.merge_threshold_16dot16_percent >> 16));
|
||||
env->me_merge_threshold_gc = (uint16_t)(
|
||||
bytes - ((env->me_options.merge_threshold_16dot16_percent > 19005)
|
||||
env->me_merge_threshold =
|
||||
(uint16_t)(bytes -
|
||||
(bytes * env->me_options.merge_threshold_16dot16_percent >>
|
||||
16));
|
||||
env->me_merge_threshold_gc =
|
||||
(uint16_t)(bytes -
|
||||
((env->me_options.merge_threshold_16dot16_percent > 19005)
|
||||
? bytes / 3 /* 33 % */
|
||||
: bytes / 4 /* 25 % */));
|
||||
}
|
||||
@ -19575,9 +19584,9 @@ __cold int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn,
|
||||
}
|
||||
|
||||
static __inline MDBX_cmp_func *get_default_keycmp(unsigned flags) {
|
||||
return (flags & MDBX_REVERSEKEY)
|
||||
? cmp_reverse
|
||||
: (flags & MDBX_INTEGERKEY) ? cmp_int_align2 : cmp_lexical;
|
||||
return (flags & MDBX_REVERSEKEY) ? cmp_reverse
|
||||
: (flags & MDBX_INTEGERKEY) ? cmp_int_align2
|
||||
: cmp_lexical;
|
||||
}
|
||||
|
||||
static __inline MDBX_cmp_func *get_default_datacmp(unsigned flags) {
|
||||
|
@ -1461,8 +1461,9 @@ MDBX_INTERNAL_FUNC int mdbx_mmap(const int flags, mdbx_mmap_t *map,
|
||||
if (!NT_SUCCESS(err))
|
||||
return ntstatus2errcode(err);
|
||||
|
||||
SIZE_T ViewSize =
|
||||
(flags & MDBX_RDONLY) ? 0 : mdbx_RunningUnderWine() ? size : limit;
|
||||
SIZE_T ViewSize = (flags & MDBX_RDONLY) ? 0
|
||||
: mdbx_RunningUnderWine() ? size
|
||||
: limit;
|
||||
err = NtMapViewOfSection(
|
||||
map->section, GetCurrentProcess(), &map->address,
|
||||
/* ZeroBits */ 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user