mirror of
				https://github.com/isar/libmdbx.git
				synced 2025-11-04 05:08:57 +08:00 
			
		
		
		
	mdbx++: больше __cold для редко-используемых функций.
				
					
				
			This commit is contained in:
		
							
								
								
									
										40
									
								
								src/mdbx.c++
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/mdbx.c++
									
									
									
									
									
								
							@@ -1291,7 +1291,7 @@ bool env::is_pristine() const {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool env::is_empty() const { return get_stat().ms_leaf_pages == 0; }
 | 
					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(
 | 
					  error::success_or_throw(
 | 
				
			||||||
      ::mdbx_env_copy2fd(handle_, fd,
 | 
					      ::mdbx_env_copy2fd(handle_, fd,
 | 
				
			||||||
                         (compactify ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) |
 | 
					                         (compactify ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) |
 | 
				
			||||||
@@ -1300,7 +1300,7 @@ env &env::copy(filehandle fd, bool compactify, bool force_dynamic_size) {
 | 
				
			|||||||
  return *this;
 | 
					  return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
env &env::copy(const char *destination, bool compactify,
 | 
					__cold env &env::copy(const char *destination, bool compactify,
 | 
				
			||||||
                      bool force_dynamic_size) {
 | 
					                      bool force_dynamic_size) {
 | 
				
			||||||
  error::success_or_throw(
 | 
					  error::success_or_throw(
 | 
				
			||||||
      ::mdbx_env_copy(handle_, destination,
 | 
					      ::mdbx_env_copy(handle_, destination,
 | 
				
			||||||
@@ -1310,13 +1310,13 @@ env &env::copy(const char *destination, bool compactify,
 | 
				
			|||||||
  return *this;
 | 
					  return *this;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
env &env::copy(const ::std::string &destination, bool compactify,
 | 
					__cold env &env::copy(const ::std::string &destination, bool compactify,
 | 
				
			||||||
                      bool force_dynamic_size) {
 | 
					                      bool force_dynamic_size) {
 | 
				
			||||||
  return copy(destination.c_str(), compactify, force_dynamic_size);
 | 
					  return copy(destination.c_str(), compactify, force_dynamic_size);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32) || defined(_WIN64)
 | 
					#if defined(_WIN32) || defined(_WIN64)
 | 
				
			||||||
env &env::copy(const wchar_t *destination, bool compactify,
 | 
					__cold env &env::copy(const wchar_t *destination, bool compactify,
 | 
				
			||||||
                      bool force_dynamic_size) {
 | 
					                      bool force_dynamic_size) {
 | 
				
			||||||
  error::success_or_throw(
 | 
					  error::success_or_throw(
 | 
				
			||||||
      ::mdbx_env_copyW(handle_, destination,
 | 
					      ::mdbx_env_copyW(handle_, destination,
 | 
				
			||||||
@@ -1333,13 +1333,13 @@ env &env::copy(const ::std::wstring &destination, bool compactify,
 | 
				
			|||||||
#endif /* Windows */
 | 
					#endif /* Windows */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef MDBX_STD_FILESYSTEM_PATH
 | 
					#ifdef MDBX_STD_FILESYSTEM_PATH
 | 
				
			||||||
env &env::copy(const MDBX_STD_FILESYSTEM_PATH &destination, bool compactify,
 | 
					__cold env &env::copy(const MDBX_STD_FILESYSTEM_PATH &destination,
 | 
				
			||||||
               bool force_dynamic_size) {
 | 
					                      bool compactify, bool force_dynamic_size) {
 | 
				
			||||||
  return copy(destination.native(), compactify, force_dynamic_size);
 | 
					  return copy(destination.native(), compactify, force_dynamic_size);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* MDBX_STD_FILESYSTEM_PATH */
 | 
					#endif /* MDBX_STD_FILESYSTEM_PATH */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
path env::get_path() const {
 | 
					__cold path env::get_path() const {
 | 
				
			||||||
#if defined(_WIN32) || defined(_WIN64)
 | 
					#if defined(_WIN32) || defined(_WIN64)
 | 
				
			||||||
  const wchar_t *c_wstr;
 | 
					  const wchar_t *c_wstr;
 | 
				
			||||||
  error::success_or_throw(::mdbx_env_get_pathW(handle_, &c_wstr));
 | 
					  error::success_or_throw(::mdbx_env_get_pathW(handle_, &c_wstr));
 | 
				
			||||||
@@ -1353,28 +1353,29 @@ path env::get_path() const {
 | 
				
			|||||||
#endif
 | 
					#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(
 | 
					  return error::boolean_or_throw(
 | 
				
			||||||
      ::mdbx_env_delete(pathname, MDBX_env_delete_mode_t(mode)));
 | 
					      ::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);
 | 
					  return remove(pathname.c_str(), mode);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32) || defined(_WIN64)
 | 
					#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(
 | 
					  return error::boolean_or_throw(
 | 
				
			||||||
      ::mdbx_env_deleteW(pathname, MDBX_env_delete_mode_t(mode)));
 | 
					      ::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);
 | 
					  return remove(pathname.c_str(), mode);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* Windows */
 | 
					#endif /* Windows */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef MDBX_STD_FILESYSTEM_PATH
 | 
					#ifdef MDBX_STD_FILESYSTEM_PATH
 | 
				
			||||||
bool env::remove(const MDBX_STD_FILESYSTEM_PATH &pathname,
 | 
					__cold bool env::remove(const MDBX_STD_FILESYSTEM_PATH &pathname,
 | 
				
			||||||
                        const remove_mode mode) {
 | 
					                        const remove_mode mode) {
 | 
				
			||||||
  return remove(pathname.native(), mode);
 | 
					  return remove(pathname.native(), mode);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1389,13 +1390,13 @@ static inline MDBX_env *create_env() {
 | 
				
			|||||||
  return ptr;
 | 
					  return ptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
env_managed::~env_managed() noexcept {
 | 
					__cold env_managed::~env_managed() noexcept {
 | 
				
			||||||
  if (MDBX_UNLIKELY(handle_))
 | 
					  if (MDBX_UNLIKELY(handle_))
 | 
				
			||||||
    MDBX_CXX20_UNLIKELY error::success_or_panic(
 | 
					    MDBX_CXX20_UNLIKELY error::success_or_panic(
 | 
				
			||||||
        ::mdbx_env_close(handle_), "mdbx::~env()", "mdbx_env_close");
 | 
					        ::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 =
 | 
					  const error rc =
 | 
				
			||||||
      static_cast<MDBX_error_t>(::mdbx_env_close_ex(handle_, dont_sync));
 | 
					      static_cast<MDBX_error_t>(::mdbx_env_close_ex(handle_, dont_sync));
 | 
				
			||||||
  switch (rc.code()) {
 | 
					  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;
 | 
					  map_handle map;
 | 
				
			||||||
  const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
 | 
					  const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
 | 
				
			||||||
  switch (err) {
 | 
					  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;
 | 
					  map_handle map;
 | 
				
			||||||
  const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
 | 
					  const int err = ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
 | 
				
			||||||
  switch (err) {
 | 
					  switch (err) {
 | 
				
			||||||
@@ -1586,7 +1587,7 @@ bool txn::clear_map(const char *name, bool throw_if_absent) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool txn::rename_map(const char *old_name, const char *new_name,
 | 
					__cold bool txn::rename_map(const char *old_name, const char *new_name,
 | 
				
			||||||
                            bool throw_if_absent) {
 | 
					                            bool throw_if_absent) {
 | 
				
			||||||
  map_handle map;
 | 
					  map_handle map;
 | 
				
			||||||
  const int err = ::mdbx_dbi_open(handle_, old_name, MDBX_DB_ACCEDE, &map.dbi);
 | 
					  const int err = ::mdbx_dbi_open(handle_, old_name, MDBX_DB_ACCEDE, &map.dbi);
 | 
				
			||||||
@@ -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,
 | 
					__cold bool txn::rename_map(const ::std::string &old_name,
 | 
				
			||||||
                     const ::std::string &new_name, bool throw_if_absent) {
 | 
					                            const ::std::string &new_name,
 | 
				
			||||||
 | 
					                            bool throw_if_absent) {
 | 
				
			||||||
  return rename_map(old_name.c_str(), new_name.c_str(), throw_if_absent);
 | 
					  return rename_map(old_name.c_str(), new_name.c_str(), throw_if_absent);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user