diff --git a/src/mdbx.c++ b/src/mdbx.c++ index 45372996..01334c5c 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -1291,7 +1291,7 @@ bool env::is_pristine() const { bool env::is_empty() const { return get_stat().ms_leaf_pages == 0; } -env &env::copy(filehandle fd, bool compactify, bool force_dynamic_size) { +__cold env &env::copy(filehandle fd, bool compactify, bool force_dynamic_size) { error::success_or_throw( ::mdbx_env_copy2fd(handle_, fd, (compactify ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) | @@ -1300,8 +1300,8 @@ env &env::copy(filehandle fd, bool compactify, bool force_dynamic_size) { return *this; } -env &env::copy(const char *destination, bool compactify, - bool force_dynamic_size) { +__cold env &env::copy(const char *destination, bool compactify, + bool force_dynamic_size) { error::success_or_throw( ::mdbx_env_copy(handle_, destination, (compactify ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) | @@ -1310,14 +1310,14 @@ env &env::copy(const char *destination, bool compactify, return *this; } -env &env::copy(const ::std::string &destination, bool compactify, - bool force_dynamic_size) { +__cold env &env::copy(const ::std::string &destination, bool compactify, + bool force_dynamic_size) { return copy(destination.c_str(), compactify, force_dynamic_size); } #if defined(_WIN32) || defined(_WIN64) -env &env::copy(const wchar_t *destination, bool compactify, - bool force_dynamic_size) { +__cold env &env::copy(const wchar_t *destination, bool compactify, + bool force_dynamic_size) { error::success_or_throw( ::mdbx_env_copyW(handle_, destination, (compactify ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) | @@ -1333,13 +1333,13 @@ env &env::copy(const ::std::wstring &destination, bool compactify, #endif /* Windows */ #ifdef MDBX_STD_FILESYSTEM_PATH -env &env::copy(const MDBX_STD_FILESYSTEM_PATH &destination, bool compactify, - bool force_dynamic_size) { +__cold env &env::copy(const MDBX_STD_FILESYSTEM_PATH &destination, + bool compactify, bool force_dynamic_size) { return copy(destination.native(), compactify, force_dynamic_size); } #endif /* MDBX_STD_FILESYSTEM_PATH */ -path env::get_path() const { +__cold path env::get_path() const { #if defined(_WIN32) || defined(_WIN64) const wchar_t *c_wstr; error::success_or_throw(::mdbx_env_get_pathW(handle_, &c_wstr)); @@ -1353,29 +1353,30 @@ path env::get_path() const { #endif } -bool env::remove(const char *pathname, const remove_mode mode) { +__cold bool env::remove(const char *pathname, const remove_mode mode) { return error::boolean_or_throw( ::mdbx_env_delete(pathname, MDBX_env_delete_mode_t(mode))); } -bool env::remove(const ::std::string &pathname, const remove_mode mode) { +__cold bool env::remove(const ::std::string &pathname, const remove_mode mode) { return remove(pathname.c_str(), mode); } #if defined(_WIN32) || defined(_WIN64) -bool env::remove(const wchar_t *pathname, const remove_mode mode) { +__cold bool env::remove(const wchar_t *pathname, const remove_mode mode) { return error::boolean_or_throw( ::mdbx_env_deleteW(pathname, MDBX_env_delete_mode_t(mode))); } -bool env::remove(const ::std::wstring &pathname, const remove_mode mode) { +__cold bool env::remove(const ::std::wstring &pathname, + const remove_mode mode) { return remove(pathname.c_str(), mode); } #endif /* Windows */ #ifdef MDBX_STD_FILESYSTEM_PATH -bool env::remove(const MDBX_STD_FILESYSTEM_PATH &pathname, - const remove_mode mode) { +__cold bool env::remove(const MDBX_STD_FILESYSTEM_PATH &pathname, + const remove_mode mode) { return remove(pathname.native(), mode); } #endif /* MDBX_STD_FILESYSTEM_PATH */ @@ -1389,13 +1390,13 @@ static inline MDBX_env *create_env() { return ptr; } -env_managed::~env_managed() noexcept { +__cold env_managed::~env_managed() noexcept { if (MDBX_UNLIKELY(handle_)) MDBX_CXX20_UNLIKELY error::success_or_panic( ::mdbx_env_close(handle_), "mdbx::~env()", "mdbx_env_close"); } -void env_managed::close(bool dont_sync) { +__cold void env_managed::close(bool dont_sync) { const error rc = static_cast(::mdbx_env_close_ex(handle_, dont_sync)); switch (rc.code()) { @@ -1552,7 +1553,7 @@ void txn_managed::commit_embark_read() { //------------------------------------------------------------------------------ -bool txn::drop_map(const char *name, bool throw_if_absent) { +__cold bool txn::drop_map(const char *name, bool throw_if_absent) { map_handle map; const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi); switch (err) { @@ -1569,7 +1570,7 @@ bool txn::drop_map(const char *name, bool throw_if_absent) { } } -bool txn::clear_map(const char *name, bool throw_if_absent) { +__cold bool txn::clear_map(const char *name, bool throw_if_absent) { map_handle map; const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi); switch (err) { @@ -1586,8 +1587,8 @@ bool txn::clear_map(const char *name, bool throw_if_absent) { } } -bool txn::rename_map(const char *old_name, const char *new_name, - bool throw_if_absent) { +__cold bool txn::rename_map(const char *old_name, const char *new_name, + bool throw_if_absent) { map_handle map; const int err = ::mdbx_dbi_open(handle_, old_name, MDBX_DB_ACCEDE, &map.dbi); switch (err) { @@ -1604,8 +1605,9 @@ bool txn::rename_map(const char *old_name, const char *new_name, } } -bool txn::rename_map(const ::std::string &old_name, - const ::std::string &new_name, bool throw_if_absent) { +__cold bool txn::rename_map(const ::std::string &old_name, + const ::std::string &new_name, + bool throw_if_absent) { return rename_map(old_name.c_str(), new_name.c_str(), throw_if_absent); }