*: 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:
@@ -65,7 +65,7 @@ Directory::Delete()
|
||||
}
|
||||
|
||||
const char *
|
||||
Directory::GetName() const
|
||||
Directory::GetName() const noexcept
|
||||
{
|
||||
assert(!IsRoot());
|
||||
|
||||
@@ -89,7 +89,7 @@ Directory::CreateChild(const char *name_utf8)
|
||||
}
|
||||
|
||||
const Directory *
|
||||
Directory::FindChild(const char *name) const
|
||||
Directory::FindChild(const char *name) const noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
|
||||
@@ -101,7 +101,7 @@ Directory::FindChild(const char *name) const
|
||||
}
|
||||
|
||||
void
|
||||
Directory::PruneEmpty()
|
||||
Directory::PruneEmpty() noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
|
||||
@@ -118,7 +118,7 @@ Directory::PruneEmpty()
|
||||
}
|
||||
|
||||
Directory::LookupResult
|
||||
Directory::LookupDirectory(const char *uri)
|
||||
Directory::LookupDirectory(const char *uri) noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
assert(uri != nullptr);
|
||||
@@ -173,7 +173,7 @@ Directory::AddSong(Song *song)
|
||||
}
|
||||
|
||||
void
|
||||
Directory::RemoveSong(Song *song)
|
||||
Directory::RemoveSong(Song *song) noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
assert(song != nullptr);
|
||||
@@ -183,7 +183,7 @@ Directory::RemoveSong(Song *song)
|
||||
}
|
||||
|
||||
const Song *
|
||||
Directory::FindSong(const char *name_utf8) const
|
||||
Directory::FindSong(const char *name_utf8) const noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
assert(name_utf8 != nullptr);
|
||||
@@ -200,13 +200,13 @@ Directory::FindSong(const char *name_utf8) const
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
directory_cmp(const Directory &a, const Directory &b)
|
||||
directory_cmp(const Directory &a, const Directory &b) noexcept
|
||||
{
|
||||
return IcuCollate(a.path.c_str(), b.path.c_str()) < 0;
|
||||
}
|
||||
|
||||
void
|
||||
Directory::Sort()
|
||||
Directory::Sort() noexcept
|
||||
{
|
||||
assert(holding_db_lock());
|
||||
|
||||
@@ -261,7 +261,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
|
||||
}
|
||||
|
||||
LightDirectory
|
||||
Directory::Export() const
|
||||
Directory::Export() const noexcept
|
||||
{
|
||||
return LightDirectory(GetPath(), mtime);
|
||||
}
|
||||
|
@@ -134,10 +134,10 @@ public:
|
||||
* Caller must lock the #db_mutex.
|
||||
*/
|
||||
gcc_pure
|
||||
const Directory *FindChild(const char *name) const;
|
||||
const Directory *FindChild(const char *name) const noexcept;
|
||||
|
||||
gcc_pure
|
||||
Directory *FindChild(const char *name) {
|
||||
Directory *FindChild(const char *name) noexcept {
|
||||
const Directory *cthis = this;
|
||||
return const_cast<Directory *>(cthis->FindChild(name));
|
||||
}
|
||||
@@ -177,10 +177,10 @@ public:
|
||||
* @return the Directory, or nullptr if none was found
|
||||
*/
|
||||
gcc_pure
|
||||
LookupResult LookupDirectory(const char *uri);
|
||||
LookupResult LookupDirectory(const char *uri) noexcept;
|
||||
|
||||
gcc_pure
|
||||
bool IsEmpty() const {
|
||||
bool IsEmpty() const noexcept {
|
||||
return children.empty() &&
|
||||
songs.empty() &&
|
||||
playlists.empty();
|
||||
@@ -195,13 +195,13 @@ public:
|
||||
* Returns the base name of the directory.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *GetName() const;
|
||||
const char *GetName() const noexcept;
|
||||
|
||||
/**
|
||||
* Is this the root directory of the music database?
|
||||
*/
|
||||
gcc_pure
|
||||
bool IsRoot() const {
|
||||
bool IsRoot() const noexcept {
|
||||
return parent == nullptr;
|
||||
}
|
||||
|
||||
@@ -229,10 +229,10 @@ public:
|
||||
* Caller must lock the #db_mutex.
|
||||
*/
|
||||
gcc_pure
|
||||
const Song *FindSong(const char *name_utf8) const;
|
||||
const Song *FindSong(const char *name_utf8) const noexcept;
|
||||
|
||||
gcc_pure
|
||||
Song *FindSong(const char *name_utf8) {
|
||||
Song *FindSong(const char *name_utf8) noexcept {
|
||||
const Directory *cthis = this;
|
||||
return const_cast<Song *>(cthis->FindSong(name_utf8));
|
||||
}
|
||||
@@ -248,19 +248,19 @@ public:
|
||||
* invalidates the song object, because the "parent" attribute becomes
|
||||
* stale), but does not free it.
|
||||
*/
|
||||
void RemoveSong(Song *song);
|
||||
void RemoveSong(Song *song) noexcept;
|
||||
|
||||
/**
|
||||
* Caller must lock the #db_mutex.
|
||||
*/
|
||||
void PruneEmpty();
|
||||
void PruneEmpty() noexcept;
|
||||
|
||||
/**
|
||||
* Sort all directory entries recursively.
|
||||
*
|
||||
* Caller must lock the #db_mutex.
|
||||
*/
|
||||
void Sort();
|
||||
void Sort() noexcept;
|
||||
|
||||
/**
|
||||
* Caller must lock #db_mutex.
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
VisitPlaylist visit_playlist) const;
|
||||
|
||||
gcc_pure
|
||||
LightDirectory Export() const;
|
||||
LightDirectory Export() const noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -40,7 +40,7 @@
|
||||
|
||||
gcc_const
|
||||
static const char *
|
||||
DeviceToTypeString(unsigned device)
|
||||
DeviceToTypeString(unsigned device) noexcept
|
||||
{
|
||||
switch (device) {
|
||||
case DEVICE_INARCHIVE:
|
||||
@@ -56,7 +56,7 @@ DeviceToTypeString(unsigned device)
|
||||
|
||||
gcc_pure
|
||||
static unsigned
|
||||
ParseTypeString(const char *type)
|
||||
ParseTypeString(const char *type) noexcept
|
||||
{
|
||||
if (strcmp(type, "archive") == 0)
|
||||
return DEVICE_INARCHIVE;
|
||||
|
@@ -77,7 +77,7 @@ Song::Free()
|
||||
}
|
||||
|
||||
std::string
|
||||
Song::GetURI() const
|
||||
Song::GetURI() const noexcept
|
||||
{
|
||||
assert(*uri);
|
||||
|
||||
@@ -96,7 +96,7 @@ Song::GetURI() const
|
||||
}
|
||||
|
||||
LightSong
|
||||
Song::Export() const
|
||||
Song::Export() const noexcept
|
||||
{
|
||||
LightSong dest;
|
||||
dest.directory = parent->IsRoot()
|
||||
|
@@ -123,10 +123,10 @@ struct Song {
|
||||
* location within the music directory.
|
||||
*/
|
||||
gcc_pure
|
||||
std::string GetURI() const;
|
||||
std::string GetURI() const noexcept;
|
||||
|
||||
gcc_pure
|
||||
LightSong Export() const;
|
||||
LightSong Export() const noexcept;
|
||||
};
|
||||
|
||||
typedef boost::intrusive::list<Song,
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
static int
|
||||
compare_utf8_string(const char *a, const char *b)
|
||||
compare_utf8_string(const char *a, const char *b) noexcept
|
||||
{
|
||||
if (a == nullptr)
|
||||
return b == nullptr ? 0 : -1;
|
||||
@@ -42,8 +42,7 @@ compare_utf8_string(const char *a, const char *b)
|
||||
* nullptr.
|
||||
*/
|
||||
static int
|
||||
compare_string_tag_item(const Tag &a, const Tag &b,
|
||||
TagType type)
|
||||
compare_string_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
|
||||
{
|
||||
return compare_utf8_string(a.GetValue(type),
|
||||
b.GetValue(type));
|
||||
@@ -54,7 +53,7 @@ compare_string_tag_item(const Tag &a, const Tag &b,
|
||||
* (e.g. disc or track number). Either one may be nullptr.
|
||||
*/
|
||||
static int
|
||||
compare_number_string(const char *a, const char *b)
|
||||
compare_number_string(const char *a, const char *b) noexcept
|
||||
{
|
||||
long ai = a == nullptr ? 0 : strtol(a, nullptr, 10);
|
||||
long bi = b == nullptr ? 0 : strtol(b, nullptr, 10);
|
||||
@@ -69,7 +68,7 @@ compare_number_string(const char *a, const char *b)
|
||||
}
|
||||
|
||||
static int
|
||||
compare_tag_item(const Tag &a, const Tag &b, TagType type)
|
||||
compare_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
|
||||
{
|
||||
return compare_number_string(a.GetValue(type),
|
||||
b.GetValue(type));
|
||||
@@ -78,7 +77,7 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type)
|
||||
/* Only used for sorting/searchin a songvec, not general purpose compares */
|
||||
gcc_pure
|
||||
static bool
|
||||
song_cmp(const Song &a, const Song &b)
|
||||
song_cmp(const Song &a, const Song &b) noexcept
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -102,7 +101,7 @@ song_cmp(const Song &a, const Song &b)
|
||||
}
|
||||
|
||||
void
|
||||
song_list_sort(SongList &songs)
|
||||
song_list_sort(SongList &songs) noexcept
|
||||
{
|
||||
songs.sort(song_cmp);
|
||||
}
|
||||
|
@@ -23,6 +23,6 @@
|
||||
#include "Song.hxx"
|
||||
|
||||
void
|
||||
song_list_sort(SongList &songs);
|
||||
song_list_sort(SongList &songs) noexcept;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user