*: 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:
@@ -53,7 +53,7 @@ IsUnsafeChar(char ch)
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
HasUnsafeChar(const char *s)
|
||||
HasUnsafeChar(const char *s) noexcept
|
||||
{
|
||||
for (; *s; ++s)
|
||||
if (IsUnsafeChar(*s))
|
||||
@@ -63,7 +63,7 @@ HasUnsafeChar(const char *s)
|
||||
}
|
||||
|
||||
static const char *
|
||||
SanitizeString(const char *s, char *buffer, size_t buffer_size)
|
||||
SanitizeString(const char *s, char *buffer, size_t buffer_size) noexcept
|
||||
{
|
||||
/* skip leading dots to avoid generating "../" sequences */
|
||||
while (*s == '.')
|
||||
@@ -79,7 +79,7 @@ SanitizeString(const char *s, char *buffer, size_t buffer_size)
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const char *
|
||||
TagGetter(const void *object, const char *name)
|
||||
TagGetter(const void *object, const char *name) noexcept
|
||||
{
|
||||
const auto &_ctx = *(const FormatTagContext *)object;
|
||||
auto &ctx = const_cast<FormatTagContext &>(_ctx);
|
||||
@@ -126,7 +126,7 @@ TagGetter(const void *object, const char *name)
|
||||
}
|
||||
|
||||
char *
|
||||
FormatTag(const Tag &tag, const char *format)
|
||||
FormatTag(const Tag &tag, const char *format) noexcept
|
||||
{
|
||||
FormatTagContext ctx(tag);
|
||||
return format_object(format, &ctx, TagGetter);
|
||||
|
@@ -27,6 +27,6 @@ struct Tag;
|
||||
|
||||
gcc_malloc gcc_nonnull_all
|
||||
char *
|
||||
FormatTag(const Tag &tag, const char *format);
|
||||
FormatTag(const Tag &tag, const char *format) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -33,7 +33,7 @@ static constexpr size_t ID3V1_SIZE = 128;
|
||||
|
||||
gcc_pure
|
||||
static inline bool
|
||||
tag_is_id3v1(struct id3_tag *tag)
|
||||
tag_is_id3v1(struct id3_tag *tag) noexcept
|
||||
{
|
||||
return (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) != 0;
|
||||
}
|
||||
|
@@ -28,14 +28,14 @@ extern tag_mask_t global_tag_mask;
|
||||
|
||||
gcc_const
|
||||
static inline bool
|
||||
IsTagEnabled(unsigned tag)
|
||||
IsTagEnabled(unsigned tag) noexcept
|
||||
{
|
||||
return global_tag_mask & (1u << tag);
|
||||
}
|
||||
|
||||
gcc_const
|
||||
static inline bool
|
||||
IsTagEnabled(TagType tag)
|
||||
IsTagEnabled(TagType tag) noexcept
|
||||
{
|
||||
return IsTagEnabled(unsigned(tag));
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <string.h>
|
||||
|
||||
TagType
|
||||
tag_name_parse(const char *name)
|
||||
tag_name_parse(const char *name) noexcept
|
||||
{
|
||||
assert(name != nullptr);
|
||||
|
||||
@@ -42,7 +42,7 @@ tag_name_parse(const char *name)
|
||||
}
|
||||
|
||||
TagType
|
||||
tag_name_parse_i(const char *name)
|
||||
tag_name_parse_i(const char *name) noexcept
|
||||
{
|
||||
assert(name != nullptr);
|
||||
|
||||
@@ -112,7 +112,7 @@ Tag::MergeReplace(Tag *base, Tag *add)
|
||||
}
|
||||
|
||||
const char *
|
||||
Tag::GetValue(TagType type) const
|
||||
Tag::GetValue(TagType type) const noexcept
|
||||
{
|
||||
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
||||
|
||||
@@ -124,7 +124,7 @@ Tag::GetValue(TagType type) const
|
||||
}
|
||||
|
||||
bool
|
||||
Tag::HasType(TagType type) const
|
||||
Tag::HasType(TagType type) const noexcept
|
||||
{
|
||||
return GetValue(type) != nullptr;
|
||||
}
|
||||
|
@@ -133,14 +133,14 @@ struct Tag {
|
||||
* nullptr if none is present in this tag object.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *GetValue(TagType type) const;
|
||||
const char *GetValue(TagType type) const noexcept;
|
||||
|
||||
/**
|
||||
* Checks whether the tag contains one or more items with
|
||||
* the specified type.
|
||||
*/
|
||||
gcc_pure
|
||||
bool HasType(TagType type) const;
|
||||
bool HasType(TagType type) const noexcept;
|
||||
|
||||
class const_iterator {
|
||||
friend struct Tag;
|
||||
@@ -202,7 +202,7 @@ struct Tag {
|
||||
*/
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_name_parse(const char *name);
|
||||
tag_name_parse(const char *name) noexcept;
|
||||
|
||||
/**
|
||||
* Parse the string, and convert it into a #TagType. Returns
|
||||
@@ -212,6 +212,6 @@ tag_name_parse(const char *name);
|
||||
*/
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_name_parse_i(const char *name);
|
||||
tag_name_parse_i(const char *name) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -153,7 +153,7 @@ TagBuilder::CommitNew()
|
||||
}
|
||||
|
||||
bool
|
||||
TagBuilder::HasType(TagType type) const
|
||||
TagBuilder::HasType(TagType type) const noexcept
|
||||
{
|
||||
for (auto i : items)
|
||||
if (i->type == type)
|
||||
@@ -237,7 +237,7 @@ TagBuilder::AddEmptyItem(TagType type)
|
||||
}
|
||||
|
||||
void
|
||||
TagBuilder::RemoveAll()
|
||||
TagBuilder::RemoveAll() noexcept
|
||||
{
|
||||
tag_pool_lock.lock();
|
||||
for (auto i : items)
|
||||
@@ -248,7 +248,7 @@ TagBuilder::RemoveAll()
|
||||
}
|
||||
|
||||
void
|
||||
TagBuilder::RemoveType(TagType type)
|
||||
TagBuilder::RemoveType(TagType type) noexcept
|
||||
{
|
||||
const auto begin = items.begin(), end = items.end();
|
||||
|
||||
|
@@ -124,7 +124,7 @@ public:
|
||||
* the specified type.
|
||||
*/
|
||||
gcc_pure
|
||||
bool HasType(TagType type) const;
|
||||
bool HasType(TagType type) const noexcept;
|
||||
|
||||
/**
|
||||
* Copy attributes and items from the other object that do not
|
||||
@@ -161,12 +161,12 @@ public:
|
||||
/**
|
||||
* Removes all tag items.
|
||||
*/
|
||||
void RemoveAll();
|
||||
void RemoveAll() noexcept;
|
||||
|
||||
/**
|
||||
* Removes all tag items of the specified type.
|
||||
*/
|
||||
void RemoveType(TagType type);
|
||||
void RemoveType(TagType type) noexcept;
|
||||
|
||||
private:
|
||||
gcc_nonnull_all
|
||||
|
@@ -57,7 +57,7 @@
|
||||
|
||||
gcc_pure
|
||||
static id3_utf8_t *
|
||||
tag_id3_getstring(const struct id3_frame *frame, unsigned i)
|
||||
tag_id3_getstring(const struct id3_frame *frame, unsigned i) noexcept
|
||||
{
|
||||
id3_field *field = id3_frame_field(frame, i);
|
||||
if (field == nullptr)
|
||||
@@ -203,7 +203,7 @@ tag_id3_import_comment(struct id3_tag *tag, const char *id, TagType type,
|
||||
*/
|
||||
gcc_pure
|
||||
static TagType
|
||||
tag_id3_parse_txxx_name(const char *name)
|
||||
tag_id3_parse_txxx_name(const char *name) noexcept
|
||||
{
|
||||
static constexpr struct tag_table txxx_tags[] = {
|
||||
{ "ALBUMARTISTSORT", TAG_ALBUM_ARTIST_SORT },
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
gcc_pure
|
||||
static const char *
|
||||
FindInvalidUTF8(const char *p, const char *const end)
|
||||
FindInvalidUTF8(const char *p, const char *const end) noexcept
|
||||
{
|
||||
while (p < end) {
|
||||
const size_t s = SequenceLengthUTF8(*p);
|
||||
|
@@ -28,7 +28,7 @@
|
||||
* in the table.
|
||||
*/
|
||||
TagType
|
||||
tag_table_lookup(const struct tag_table *table, const char *name)
|
||||
tag_table_lookup(const struct tag_table *table, const char *name) noexcept
|
||||
{
|
||||
for (; table->name != nullptr; ++table)
|
||||
if (strcmp(name, table->name) == 0)
|
||||
@@ -43,7 +43,7 @@ tag_table_lookup(const struct tag_table *table, const char *name)
|
||||
* in the table.
|
||||
*/
|
||||
TagType
|
||||
tag_table_lookup_i(const struct tag_table *table, const char *name)
|
||||
tag_table_lookup_i(const struct tag_table *table, const char *name) noexcept
|
||||
{
|
||||
for (; table->name != nullptr; ++table)
|
||||
if (StringEqualsCaseASCII(name, table->name))
|
||||
@@ -53,7 +53,7 @@ tag_table_lookup_i(const struct tag_table *table, const char *name)
|
||||
}
|
||||
|
||||
const char *
|
||||
tag_table_lookup(const tag_table *table, TagType type)
|
||||
tag_table_lookup(const tag_table *table, TagType type) noexcept
|
||||
{
|
||||
for (; table->name != nullptr; ++table)
|
||||
if (table->type == type)
|
||||
|
@@ -36,7 +36,7 @@ struct tag_table {
|
||||
*/
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_table_lookup(const tag_table *table, const char *name);
|
||||
tag_table_lookup(const tag_table *table, const char *name) noexcept;
|
||||
|
||||
/**
|
||||
* Looks up a string in a tag translation table (case insensitive).
|
||||
@@ -45,7 +45,7 @@ tag_table_lookup(const tag_table *table, const char *name);
|
||||
*/
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_table_lookup_i(const tag_table *table, const char *name);
|
||||
tag_table_lookup_i(const tag_table *table, const char *name) noexcept;
|
||||
|
||||
/**
|
||||
* Looks up a #TagType in a tag translation table and returns its
|
||||
@@ -54,6 +54,6 @@ tag_table_lookup_i(const tag_table *table, const char *name);
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
tag_table_lookup(const tag_table *table, TagType type);
|
||||
tag_table_lookup(const tag_table *table, TagType type) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
const char *
|
||||
vorbis_comment_value(const char *entry, const char *name)
|
||||
vorbis_comment_value(const char *entry, const char *name) noexcept
|
||||
{
|
||||
assert(entry != nullptr);
|
||||
assert(name != nullptr);
|
||||
|
@@ -29,6 +29,6 @@
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
vorbis_comment_value(const char *entry, const char *name);
|
||||
vorbis_comment_value(const char *entry, const char *name) noexcept;
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user