mirror of
https://github.com/isar/libmdbx.git
synced 2025-04-01 02:32:57 +08:00
mdbx++: переформатирование (временно) неиспользуемого кода (backport).
This commit is contained in:
parent
c5936eb5da
commit
682233ba28
25
src/mdbx.c++
25
src/mdbx.c++
@ -63,8 +63,8 @@ class trouble_location {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MDBX_CXX11_CONSTEXPR trouble_location(unsigned line, const char *condition,
|
MDBX_CXX11_CONSTEXPR trouble_location(unsigned line, const char *condition, const char *function,
|
||||||
const char *function, const char *filename)
|
const char *filename)
|
||||||
:
|
:
|
||||||
#if TROUBLE_PROVIDE_LINENO
|
#if TROUBLE_PROVIDE_LINENO
|
||||||
line_(line)
|
line_(line)
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
__cold std::string format_va(const char *fmt, va_list ap) {
|
__cold std::string format_va(const char *fmt, va_list ap) {
|
||||||
va_list ones;
|
va_list ones;
|
||||||
va_copy(ones, ap);
|
va_copy(ones, ap);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -146,15 +146,14 @@ __cold std::string format_va(const char *fmt, va_list ap) {
|
|||||||
result.reserve(size_t(needed + 1));
|
result.reserve(size_t(needed + 1));
|
||||||
result.resize(size_t(needed), '\0');
|
result.resize(size_t(needed), '\0');
|
||||||
assert(int(result.capacity()) > needed);
|
assert(int(result.capacity()) > needed);
|
||||||
int actual = vsnprintf(const_cast<char *>(result.data()), result.capacity(),
|
int actual = vsnprintf(const_cast<char *>(result.data()), result.capacity(), fmt, ones);
|
||||||
fmt, ones);
|
|
||||||
assert(actual == needed);
|
assert(actual == needed);
|
||||||
(void)actual;
|
(void)actual;
|
||||||
va_end(ones);
|
va_end(ones);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
__cold std::string format(const char *fmt, ...) {
|
__cold std::string format(const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
std::string result = format_va(fmt, ap);
|
std::string result = format_va(fmt, ap);
|
||||||
@ -175,17 +174,14 @@ public:
|
|||||||
virtual ~bug() noexcept;
|
virtual ~bug() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
__cold bug::bug(const trouble_location &location) noexcept
|
__cold bug::bug(const trouble_location &location) noexcept
|
||||||
: std::runtime_error(format("mdbx.bug: %s.%s at %s:%u", location.function(),
|
: std::runtime_error(format("mdbx.bug: %s.%s at %s:%u", location.function(), location.condition(),
|
||||||
location.condition(), location.filename(),
|
location.filename(), location.line())),
|
||||||
location.line())),
|
|
||||||
location_(location) {}
|
location_(location) {}
|
||||||
|
|
||||||
__cold bug::~bug() noexcept {}
|
__cold bug::~bug() noexcept {}
|
||||||
|
|
||||||
[[noreturn]] __cold void raise_bug(const trouble_location &what_and_where) {
|
[[maybe_unused, noreturn]] __cold void raise_bug(const trouble_location &what_and_where) { throw bug(what_and_where); }
|
||||||
throw bug(what_and_where);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RAISE_BUG(line, condition, function, file) \
|
#define RAISE_BUG(line, condition, function, file) \
|
||||||
do { \
|
do { \
|
||||||
@ -193,6 +189,7 @@ __cold bug::~bug() noexcept {}
|
|||||||
raise_bug(bug); \
|
raise_bug(bug); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#undef ENSURE
|
||||||
#define ENSURE(condition) \
|
#define ENSURE(condition) \
|
||||||
do \
|
do \
|
||||||
if (MDBX_UNLIKELY(!(condition))) \
|
if (MDBX_UNLIKELY(!(condition))) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user