*: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to consider these functions throwing.
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
AllocatedPath::~AllocatedPath() {}
|
||||
|
||||
AllocatedPath
|
||||
AllocatedPath::FromUTF8(const char *path_utf8)
|
||||
AllocatedPath::FromUTF8(const char *path_utf8) noexcept
|
||||
{
|
||||
#if defined(HAVE_FS_CHARSET) || defined(WIN32)
|
||||
try {
|
||||
@@ -53,13 +53,13 @@ AllocatedPath::FromUTF8Throw(const char *path_utf8)
|
||||
}
|
||||
|
||||
AllocatedPath
|
||||
AllocatedPath::GetDirectoryName() const
|
||||
AllocatedPath::GetDirectoryName() const noexcept
|
||||
{
|
||||
return FromFS(PathTraitsFS::GetParent(c_str()));
|
||||
}
|
||||
|
||||
std::string
|
||||
AllocatedPath::ToUTF8() const
|
||||
AllocatedPath::ToUTF8() const noexcept
|
||||
{
|
||||
try {
|
||||
return ::PathToUTF8(c_str());
|
||||
@@ -69,7 +69,7 @@ AllocatedPath::ToUTF8() const
|
||||
}
|
||||
|
||||
void
|
||||
AllocatedPath::ChopSeparators()
|
||||
AllocatedPath::ChopSeparators() noexcept
|
||||
{
|
||||
size_t l = length();
|
||||
const auto *p = data();
|
||||
|
@@ -153,7 +153,7 @@ public:
|
||||
* Returns return a "nulled" instance on error.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static AllocatedPath FromUTF8(const char *path_utf8);
|
||||
static AllocatedPath FromUTF8(const char *path_utf8) noexcept;
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 C string to an #AllocatedPath instance.
|
||||
@@ -244,14 +244,14 @@ public:
|
||||
* (#IsNull returns true).
|
||||
*/
|
||||
gcc_pure
|
||||
std::string ToUTF8() const;
|
||||
std::string ToUTF8() const noexcept;
|
||||
|
||||
/**
|
||||
* Gets directory name of this path.
|
||||
* Returns a "nulled" instance on error.
|
||||
*/
|
||||
gcc_pure
|
||||
AllocatedPath GetDirectoryName() const;
|
||||
AllocatedPath GetDirectoryName() const noexcept;
|
||||
|
||||
/**
|
||||
* Determine the relative part of the given path to this
|
||||
@@ -260,17 +260,17 @@ public:
|
||||
* nullptr on mismatch.
|
||||
*/
|
||||
gcc_pure
|
||||
const_pointer_type Relative(Path other_fs) const {
|
||||
const_pointer_type Relative(Path other_fs) const noexcept {
|
||||
return PathTraitsFS::Relative(c_str(), other_fs.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Chop trailing directory separators.
|
||||
*/
|
||||
void ChopSeparators();
|
||||
void ChopSeparators() noexcept;
|
||||
|
||||
gcc_pure
|
||||
bool IsAbsolute() const {
|
||||
bool IsAbsolute() const noexcept {
|
||||
return PathTraitsFS::IsAbsolute(c_str());
|
||||
}
|
||||
};
|
||||
|
@@ -57,7 +57,7 @@ SetFSCharset(const char *charset)
|
||||
#endif
|
||||
|
||||
void
|
||||
DeinitFSCharset()
|
||||
DeinitFSCharset() noexcept
|
||||
{
|
||||
#ifdef HAVE_ICU_CONVERTER
|
||||
delete fs_converter;
|
||||
@@ -66,7 +66,7 @@ DeinitFSCharset()
|
||||
}
|
||||
|
||||
const char *
|
||||
GetFSCharset()
|
||||
GetFSCharset() noexcept
|
||||
{
|
||||
#ifdef HAVE_FS_CHARSET
|
||||
return fs_charset.empty() ? "UTF-8" : fs_charset.c_str();
|
||||
|
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
gcc_const
|
||||
const char *
|
||||
GetFSCharset();
|
||||
GetFSCharset() noexcept;
|
||||
|
||||
/**
|
||||
* Throws std::runtime_error on error.
|
||||
@@ -42,7 +42,7 @@ void
|
||||
SetFSCharset(const char *charset);
|
||||
|
||||
void
|
||||
DeinitFSCharset();
|
||||
DeinitFSCharset() noexcept;
|
||||
|
||||
/**
|
||||
* Convert the path to UTF-8.
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
std::string
|
||||
Path::ToUTF8() const
|
||||
Path::ToUTF8() const noexcept
|
||||
{
|
||||
try {
|
||||
return ::PathToUTF8(c_str());
|
||||
@@ -34,7 +34,7 @@ Path::ToUTF8() const
|
||||
}
|
||||
|
||||
Path::const_pointer_type
|
||||
Path::GetSuffix() const
|
||||
Path::GetSuffix() const noexcept
|
||||
{
|
||||
const auto base = GetBase().c_str();
|
||||
const auto *dot = StringFindLast(base, '.');
|
||||
|
@@ -123,7 +123,7 @@ public:
|
||||
* transfer newline characters).
|
||||
*/
|
||||
gcc_pure
|
||||
bool HasNewline() const {
|
||||
bool HasNewline() const noexcept {
|
||||
return PathTraitsFS::Find(c_str(), '\n') != nullptr;
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ public:
|
||||
* (#IsNull returns true).
|
||||
*/
|
||||
gcc_pure
|
||||
std::string ToUTF8() const;
|
||||
std::string ToUTF8() const noexcept;
|
||||
|
||||
/**
|
||||
* Determine the "base" file name.
|
||||
* The return value points inside this object.
|
||||
*/
|
||||
gcc_pure
|
||||
Path GetBase() const {
|
||||
Path GetBase() const noexcept {
|
||||
return FromFS(PathTraitsFS::GetBase(c_str()));
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
* Returns a "nulled" instance on error.
|
||||
*/
|
||||
gcc_pure
|
||||
AllocatedPath GetDirectoryName() const;
|
||||
AllocatedPath GetDirectoryName() const noexcept;
|
||||
|
||||
/**
|
||||
* Determine the relative part of the given path to this
|
||||
@@ -158,17 +158,17 @@ public:
|
||||
* nullptr on mismatch.
|
||||
*/
|
||||
gcc_pure
|
||||
const_pointer_type Relative(Path other_fs) const {
|
||||
const_pointer_type Relative(Path other_fs) const noexcept {
|
||||
return PathTraitsFS::Relative(c_str(), other_fs.c_str());
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool IsAbsolute() const {
|
||||
bool IsAbsolute() const noexcept {
|
||||
return PathTraitsFS::IsAbsolute(c_str());
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
const_pointer_type GetSuffix() const;
|
||||
const_pointer_type GetSuffix() const noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "AllocatedPath.hxx"
|
||||
|
||||
AllocatedPath
|
||||
Path::GetDirectoryName() const
|
||||
Path::GetDirectoryName() const noexcept
|
||||
{
|
||||
return AllocatedPath::FromFS(PathTraitsFS::GetParent(c_str()));
|
||||
}
|
||||
|
@@ -202,7 +202,8 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
static AllocatedPath GetUserDir(const char *name)
|
||||
static AllocatedPath
|
||||
GetUserDir(const char *name) noexcept
|
||||
try {
|
||||
auto result = AllocatedPath::Null();
|
||||
auto config_dir = GetUserConfigDir();
|
||||
@@ -222,7 +223,8 @@ try {
|
||||
|
||||
#endif
|
||||
|
||||
AllocatedPath GetUserConfigDir()
|
||||
AllocatedPath
|
||||
GetUserConfigDir() noexcept
|
||||
{
|
||||
#if defined(WIN32)
|
||||
return GetStandardDir(CSIDL_LOCAL_APPDATA);
|
||||
@@ -246,7 +248,8 @@ AllocatedPath GetUserConfigDir()
|
||||
#endif
|
||||
}
|
||||
|
||||
AllocatedPath GetUserMusicDir()
|
||||
AllocatedPath
|
||||
GetUserMusicDir() noexcept
|
||||
{
|
||||
#if defined(WIN32)
|
||||
return GetStandardDir(CSIDL_MYMUSIC);
|
||||
@@ -259,7 +262,8 @@ AllocatedPath GetUserMusicDir()
|
||||
#endif
|
||||
}
|
||||
|
||||
AllocatedPath GetUserCacheDir()
|
||||
AllocatedPath
|
||||
GetUserCacheDir() noexcept
|
||||
{
|
||||
#ifdef USE_XDG
|
||||
// Check for $XDG_CACHE_HOME
|
||||
@@ -285,12 +289,14 @@ AllocatedPath GetUserCacheDir()
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
AllocatedPath GetSystemConfigDir()
|
||||
AllocatedPath
|
||||
GetSystemConfigDir() noexcept
|
||||
{
|
||||
return GetStandardDir(CSIDL_COMMON_APPDATA);
|
||||
}
|
||||
|
||||
AllocatedPath GetAppBaseDir()
|
||||
AllocatedPath
|
||||
GetAppBaseDir() noexcept
|
||||
{
|
||||
std::array<PathTraitsFS::value_type, MAX_PATH> app;
|
||||
auto ret = GetModuleFileName(nullptr, app.data(), app.size());
|
||||
@@ -309,7 +315,8 @@ AllocatedPath GetAppBaseDir()
|
||||
|
||||
#else
|
||||
|
||||
AllocatedPath GetHomeDir()
|
||||
AllocatedPath
|
||||
GetHomeDir() noexcept
|
||||
{
|
||||
#ifndef ANDROID
|
||||
auto home = getenv("HOME");
|
||||
@@ -322,7 +329,8 @@ AllocatedPath GetHomeDir()
|
||||
return AllocatedPath::Null();
|
||||
}
|
||||
|
||||
AllocatedPath GetHomeDir(const char *user_name)
|
||||
AllocatedPath
|
||||
GetHomeDir(const char *user_name) noexcept
|
||||
{
|
||||
#ifdef ANDROID
|
||||
(void)user_name;
|
||||
|
@@ -26,45 +26,51 @@
|
||||
/**
|
||||
* Obtains configuration directory for the current user.
|
||||
*/
|
||||
AllocatedPath GetUserConfigDir();
|
||||
AllocatedPath
|
||||
GetUserConfigDir() noexcept;
|
||||
|
||||
/**
|
||||
* Obtains music directory for the current user.
|
||||
*/
|
||||
AllocatedPath GetUserMusicDir();
|
||||
AllocatedPath
|
||||
GetUserMusicDir() noexcept;
|
||||
|
||||
/**
|
||||
* Obtains cache directory for the current user.
|
||||
*/
|
||||
gcc_pure
|
||||
AllocatedPath
|
||||
GetUserCacheDir();
|
||||
GetUserCacheDir() noexcept;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
/**
|
||||
* Obtains system configuration directory.
|
||||
*/
|
||||
AllocatedPath GetSystemConfigDir();
|
||||
AllocatedPath
|
||||
GetSystemConfigDir() noexcept;
|
||||
|
||||
/**
|
||||
* Obtains application application base directory.
|
||||
* Application base directory is a directory that contains 'bin' folder
|
||||
* for current executable.
|
||||
*/
|
||||
AllocatedPath GetAppBaseDir();
|
||||
AllocatedPath
|
||||
GetAppBaseDir() noexcept;
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Obtains home directory for the current user.
|
||||
*/
|
||||
AllocatedPath GetHomeDir();
|
||||
AllocatedPath
|
||||
GetHomeDir() noexcept;
|
||||
|
||||
/**
|
||||
* Obtains home directory for the specified user.
|
||||
*/
|
||||
AllocatedPath GetHomeDir(const char *user_name);
|
||||
AllocatedPath
|
||||
GetHomeDir(const char *user_name) noexcept;
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -114,50 +114,51 @@ RelativePathImpl(typename Traits::const_pointer_type base,
|
||||
|
||||
PathTraitsFS::string
|
||||
PathTraitsFS::Build(const_pointer_type a, size_t a_size,
|
||||
const_pointer_type b, size_t b_size)
|
||||
const_pointer_type b, size_t b_size) noexcept
|
||||
{
|
||||
return BuildPathImpl<PathTraitsFS>(a, a_size, b, b_size);
|
||||
}
|
||||
|
||||
PathTraitsFS::const_pointer_type
|
||||
PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p)
|
||||
PathTraitsFS::GetBase(PathTraitsFS::const_pointer_type p) noexcept
|
||||
{
|
||||
return GetBasePathImpl<PathTraitsFS>(p);
|
||||
}
|
||||
|
||||
PathTraitsFS::string
|
||||
PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p)
|
||||
PathTraitsFS::GetParent(PathTraitsFS::const_pointer_type p) noexcept
|
||||
{
|
||||
return GetParentPathImpl<PathTraitsFS>(p);
|
||||
}
|
||||
|
||||
PathTraitsFS::const_pointer_type
|
||||
PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other)
|
||||
PathTraitsFS::Relative(const_pointer_type base, const_pointer_type other) noexcept
|
||||
{
|
||||
return RelativePathImpl<PathTraitsFS>(base, other);
|
||||
}
|
||||
|
||||
PathTraitsUTF8::string
|
||||
PathTraitsUTF8::Build(const_pointer_type a, size_t a_size,
|
||||
const_pointer_type b, size_t b_size)
|
||||
const_pointer_type b, size_t b_size) noexcept
|
||||
{
|
||||
return BuildPathImpl<PathTraitsUTF8>(a, a_size, b, b_size);
|
||||
}
|
||||
|
||||
PathTraitsUTF8::const_pointer_type
|
||||
PathTraitsUTF8::GetBase(const_pointer_type p)
|
||||
PathTraitsUTF8::GetBase(const_pointer_type p) noexcept
|
||||
{
|
||||
return GetBasePathImpl<PathTraitsUTF8>(p);
|
||||
}
|
||||
|
||||
PathTraitsUTF8::string
|
||||
PathTraitsUTF8::GetParent(const_pointer_type p)
|
||||
PathTraitsUTF8::GetParent(const_pointer_type p) noexcept
|
||||
{
|
||||
return GetParentPathImpl<PathTraitsUTF8>(p);
|
||||
}
|
||||
|
||||
PathTraitsUTF8::const_pointer_type
|
||||
PathTraitsUTF8::Relative(const_pointer_type base, const_pointer_type other)
|
||||
PathTraitsUTF8::Relative(const_pointer_type base,
|
||||
const_pointer_type other) noexcept
|
||||
{
|
||||
return RelativePathImpl<PathTraitsUTF8>(base, other);
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ struct PathTraitsFS {
|
||||
* The return value points inside the given string.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer_type GetBase(const_pointer_type p);
|
||||
static const_pointer_type GetBase(const_pointer_type p) noexcept;
|
||||
|
||||
/**
|
||||
* Determine the "parent" file name of the given native path.
|
||||
@@ -132,7 +132,7 @@ struct PathTraitsFS {
|
||||
* separator in the given input string.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string GetParent(const_pointer_type p);
|
||||
static string GetParent(const_pointer_type p) noexcept;
|
||||
|
||||
/**
|
||||
* Determine the relative part of the given path to this
|
||||
@@ -142,7 +142,7 @@ struct PathTraitsFS {
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer_type Relative(const_pointer_type base,
|
||||
const_pointer_type other);
|
||||
const_pointer_type other) noexcept;
|
||||
|
||||
/**
|
||||
* Constructs the path from the given components.
|
||||
@@ -152,10 +152,10 @@ struct PathTraitsFS {
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string Build(const_pointer_type a, size_t a_size,
|
||||
const_pointer_type b, size_t b_size);
|
||||
const_pointer_type b, size_t b_size) noexcept;
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string Build(const_pointer_type a, const_pointer_type b) {
|
||||
static string Build(const_pointer_type a, const_pointer_type b) noexcept {
|
||||
return Build(a, GetLength(a), b, GetLength(b));
|
||||
}
|
||||
};
|
||||
@@ -224,7 +224,7 @@ struct PathTraitsUTF8 {
|
||||
* The return value points inside the given string.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer_type GetBase(const_pointer_type p);
|
||||
static const_pointer_type GetBase(const_pointer_type p) noexcept;
|
||||
|
||||
/**
|
||||
* Determine the "parent" file name of the given UTF-8 path.
|
||||
@@ -232,7 +232,7 @@ struct PathTraitsUTF8 {
|
||||
* separator in the given input string.
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string GetParent(const_pointer_type p);
|
||||
static string GetParent(const_pointer_type p) noexcept;
|
||||
|
||||
/**
|
||||
* Determine the relative part of the given path to this
|
||||
@@ -242,7 +242,7 @@ struct PathTraitsUTF8 {
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer_type Relative(const_pointer_type base,
|
||||
const_pointer_type other);
|
||||
const_pointer_type other) noexcept;
|
||||
|
||||
/**
|
||||
* Constructs the path from the given components.
|
||||
@@ -252,7 +252,7 @@ struct PathTraitsUTF8 {
|
||||
*/
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string Build(const_pointer_type a, size_t a_size,
|
||||
const_pointer_type b, size_t b_size);
|
||||
const_pointer_type b, size_t b_size) noexcept;
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static string Build(const_pointer_type a, const_pointer_type b) {
|
||||
|
@@ -28,7 +28,7 @@ AutoGunzipReader::~AutoGunzipReader()
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
IsGzip(const uint8_t data[4])
|
||||
IsGzip(const uint8_t data[4]) noexcept
|
||||
{
|
||||
return data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08 &&
|
||||
(data[3] & 0xe0) == 0;
|
||||
|
@@ -78,7 +78,7 @@ FileOutputStream::OpenAppend(bool create)
|
||||
}
|
||||
|
||||
uint64_t
|
||||
FileOutputStream::Tell() const
|
||||
FileOutputStream::Tell() const noexcept
|
||||
{
|
||||
LONG high = 0;
|
||||
DWORD low = SetFilePointer(handle, 0, &high, FILE_CURRENT);
|
||||
@@ -184,7 +184,7 @@ FileOutputStream::OpenAppend(bool create)
|
||||
}
|
||||
|
||||
uint64_t
|
||||
FileOutputStream::Tell() const
|
||||
FileOutputStream::Tell() const noexcept
|
||||
{
|
||||
return fd.Tell();
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
uint64_t Tell() const;
|
||||
uint64_t Tell() const noexcept;
|
||||
|
||||
/* virtual methods from class OutputStream */
|
||||
void Write(const void *data, size_t size) override;
|
||||
|
@@ -90,7 +90,7 @@ public:
|
||||
FileInfo GetFileInfo() const;
|
||||
|
||||
gcc_pure
|
||||
uint64_t GetSize() const {
|
||||
uint64_t GetSize() const noexcept {
|
||||
#ifdef WIN32
|
||||
LARGE_INTEGER size;
|
||||
return GetFileSizeEx(handle, &size)
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
uint64_t GetPosition() const {
|
||||
uint64_t GetPosition() const noexcept {
|
||||
#ifdef WIN32
|
||||
LARGE_INTEGER zero;
|
||||
zero.QuadPart = 0;
|
||||
|
Reference in New Issue
Block a user