more [[gnu::...]] attributes

This commit is contained in:
Max Kellermann
2021-10-13 11:28:04 +02:00
parent 1c4b484a56
commit f510564d9d
135 changed files with 361 additions and 514 deletions

View File

@@ -21,7 +21,6 @@
#define MPD_AND_SONG_FILTER_HXX
#include "ISongFilter.hxx"
#include "util/Compiler.h"
#include <list>
@@ -44,7 +43,7 @@ public:
items.emplace_back(std::forward<I>(_item));
}
gcc_pure
[[gnu::pure]]
bool IsEmpty() const noexcept {
return items.empty();
}

View File

@@ -23,7 +23,6 @@
#include "tag/Tag.hxx"
#include "pcm/AudioFormat.hxx"
#include "Chrono.hxx"
#include "util/Compiler.h"
#include <chrono>
#include <string>
@@ -108,7 +107,6 @@ public:
*/
explicit DetachedSong(const LightSong &other) noexcept;
gcc_noinline
~DetachedSong() noexcept = default;
/* these are declared because the user-defined destructor
@@ -117,10 +115,10 @@ public:
DetachedSong(DetachedSong &&) = default;
DetachedSong &operator=(DetachedSong &&) = default;
gcc_pure
[[gnu::pure]]
explicit operator LightSong() const noexcept;
gcc_pure
[[gnu::pure]]
const char *GetURI() const noexcept {
return uri.c_str();
}
@@ -134,7 +132,7 @@ public:
* Does this object have a "real" URI different from the
* displayed URI?
*/
gcc_pure
[[gnu::pure]]
bool HasRealURI() const noexcept {
return !real_uri.empty();
}
@@ -143,7 +141,7 @@ public:
* Returns "real" URI (#real_uri) and falls back to just
* GetURI().
*/
gcc_pure
[[gnu::pure]]
const char *GetRealURI() const noexcept {
return (HasRealURI() ? real_uri : uri).c_str();
}
@@ -157,35 +155,35 @@ public:
* Returns true if both objects refer to the same physical
* song.
*/
gcc_pure
[[gnu::pure]]
bool IsSame(const DetachedSong &other) const noexcept {
return uri == other.uri &&
start_time == other.start_time &&
end_time == other.end_time;
}
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
bool IsURI(const char *other_uri) const noexcept {
return uri == other_uri;
}
gcc_pure gcc_nonnull_all
[[gnu::pure]] [[gnu::nonnull]]
bool IsRealURI(const char *other_uri) const noexcept {
return (HasRealURI() ? real_uri : uri) == other_uri;
}
gcc_pure
[[gnu::pure]]
bool IsRemote() const noexcept;
gcc_pure
[[gnu::pure]]
bool IsFile() const noexcept {
return !IsRemote();
}
gcc_pure
[[gnu::pure]]
bool IsAbsoluteFile() const noexcept;
gcc_pure
[[gnu::pure]]
bool IsInDatabase() const noexcept;
const Tag &GetTag() const noexcept {
@@ -240,7 +238,7 @@ public:
end_time = _value;
}
gcc_pure
[[gnu::pure]]
SignedSongTime GetDuration() const noexcept;
const AudioFormat &GetAudioFormat() const noexcept {

View File

@@ -21,7 +21,6 @@
#define MPD_SONG_FILTER_HXX
#include "AndSongFilter.hxx"
#include "util/Compiler.h"
#include <cstdint>
#include <string>
@@ -42,7 +41,6 @@ class SongFilter {
public:
SongFilter() = default;
gcc_nonnull(3)
SongFilter(TagType tag, const char *value, bool fold_case=false);
~SongFilter();
@@ -59,7 +57,6 @@ public:
private:
static ISongFilterPtr ParseExpression(const char *&s, bool fold_case=false);
gcc_nonnull(2,3)
void Parse(const char *tag, const char *value, bool fold_case=false);
public:
@@ -70,14 +67,14 @@ public:
void Optimize() noexcept;
gcc_pure
[[gnu::pure]]
bool Match(const LightSong &song) const noexcept;
const auto &GetItems() const noexcept {
return and_filter.GetItems();
}
gcc_pure
[[gnu::pure]]
bool IsEmpty() const noexcept {
return and_filter.IsEmpty();
}
@@ -85,20 +82,20 @@ public:
/**
* Is there at least one item with "fold case" enabled?
*/
gcc_pure
[[gnu::pure]]
bool HasFoldCase() const noexcept;
/**
* Does this filter contain constraints other than "base"?
*/
gcc_pure
[[gnu::pure]]
bool HasOtherThanBase() const noexcept;
/**
* Returns the "base" specification (if there is one) or
* nullptr.
*/
gcc_pure
[[gnu::pure]]
const char *GetBase() const noexcept;
/**

View File

@@ -20,8 +20,6 @@
#ifndef MPD_I_SONG_FILTER_HXX
#define MPD_I_SONG_FILTER_HXX
#include "util/Compiler.h"
#include <memory>
#include <string>
@@ -41,7 +39,7 @@ public:
*/
virtual std::string ToExpression() const noexcept = 0;
gcc_pure
[[gnu::pure]]
virtual bool Match(const LightSong &song) const noexcept = 0;
};

View File

@@ -22,7 +22,6 @@
#include "Chrono.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/Compiler.h"
#include <string>
#include <chrono>
@@ -101,7 +100,7 @@ struct LightSong {
start_time(src.start_time), end_time(src.end_time),
audio_format(src.audio_format) {}
gcc_pure
[[gnu::pure]]
std::string GetURI() const noexcept {
if (directory == nullptr)
return std::string(uri);
@@ -112,7 +111,7 @@ struct LightSong {
return result;
}
gcc_pure
[[gnu::pure]]
SignedSongTime GetDuration() const noexcept;
};

View File

@@ -21,7 +21,6 @@
#define MPD_STRING_FILTER_HXX
#include "lib/icu/Compare.hxx"
#include "util/Compiler.h"
#include "config.h"
#ifdef HAVE_PCRE
@@ -102,13 +101,13 @@ public:
: (negated ? "!=" : "=="));
}
gcc_pure
[[gnu::pure]]
bool Match(const char *s) const noexcept;
/**
* Like Match(), but ignore the "negated" flag.
*/
gcc_pure
[[gnu::pure]]
bool MatchWithoutNegation(const char *s) const noexcept;
};