*: 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:
Max Kellermann
2017-05-08 14:44:49 +02:00
parent ac2e4e593d
commit 71f0ed8b74
272 changed files with 873 additions and 846 deletions

View File

@@ -66,7 +66,7 @@ struct AudioFileInputStream {
gcc_pure
static SongTime
audiofile_get_duration(AFfilehandle fh)
audiofile_get_duration(AFfilehandle fh) noexcept
{
return SongTime::FromScale<uint64_t>(afGetFrameCount(fh, AF_DEFAULT_TRACK),
afGetRate(fh, AF_DEFAULT_TRACK));
@@ -239,7 +239,7 @@ audiofile_stream_decode(DecoderClient &client, InputStream &is)
gcc_pure
static SignedSongTime
audiofile_get_duration(InputStream &is)
audiofile_get_duration(InputStream &is) noexcept
{
if (!is.IsSeekable() || !is.KnownSize())
return SignedSongTime::Negative();

View File

@@ -39,7 +39,7 @@
#include <stdlib.h>
bool
DsdId::Equals(const char *s) const
DsdId::Equals(const char *s) const noexcept
{
assert(s != nullptr);
assert(strlen(s) == sizeof(value));
@@ -95,7 +95,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
}
bool
dsdlib_valid_freq(uint32_t samplefreq)
dsdlib_valid_freq(uint32_t samplefreq) noexcept
{
switch (samplefreq) {
case 2822400: /* DSD64, 64xFs, Fs = 44.100kHz */

View File

@@ -34,7 +34,7 @@ struct DsdId {
char value[4];
gcc_pure
bool Equals(const char *s) const;
bool Equals(const char *s) const noexcept;
};
class DsdUint64 {
@@ -72,7 +72,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
**/
gcc_const
bool
dsdlib_valid_freq(uint32_t samplefreq);
dsdlib_valid_freq(uint32_t samplefreq) noexcept;
/**
* Add tags from ID3 tag. All tags commonly found in the ID3 tags of

View File

@@ -112,14 +112,14 @@ ffmpeg_finish()
gcc_pure
static const AVCodecParameters &
GetCodecParameters(const AVStream &stream)
GetCodecParameters(const AVStream &stream) noexcept
{
return *stream.codecpar;
}
gcc_pure
static AVSampleFormat
GetSampleFormat(const AVCodecParameters &codec_params)
GetSampleFormat(const AVCodecParameters &codec_params) noexcept
{
return AVSampleFormat(codec_params.format);
}
@@ -128,14 +128,14 @@ GetSampleFormat(const AVCodecParameters &codec_params)
gcc_pure
static const AVCodecContext &
GetCodecParameters(const AVStream &stream)
GetCodecParameters(const AVStream &stream) noexcept
{
return *stream.codec;
}
gcc_pure
static AVSampleFormat
GetSampleFormat(const AVCodecContext &codec_context)
GetSampleFormat(const AVCodecContext &codec_context) noexcept
{
return codec_context.sample_fmt;
}
@@ -144,14 +144,14 @@ GetSampleFormat(const AVCodecContext &codec_context)
gcc_pure
static bool
IsAudio(const AVStream &stream)
IsAudio(const AVStream &stream) noexcept
{
return GetCodecParameters(stream).codec_type == AVMEDIA_TYPE_AUDIO;
}
gcc_pure
static int
ffmpeg_find_audio_stream(const AVFormatContext &format_context)
ffmpeg_find_audio_stream(const AVFormatContext &format_context) noexcept
{
for (unsigned i = 0; i < format_context.nb_streams; ++i)
if (IsAudio(*format_context.streams[i]))
@@ -220,7 +220,7 @@ copy_interleave_frame(const AVCodecContext &codec_context,
*/
gcc_pure
static int64_t
StreamRelativePts(const AVPacket &packet, const AVStream &stream)
StreamRelativePts(const AVPacket &packet, const AVStream &stream) noexcept
{
auto pts = packet.pts;
if (pts < 0 || pts == int64_t(AV_NOPTS_VALUE))
@@ -237,7 +237,7 @@ StreamRelativePts(const AVPacket &packet, const AVStream &stream)
gcc_pure
static uint64_t
PtsToPcmFrame(uint64_t pts, const AVStream &stream,
const AVCodecContext &codec_context)
const AVCodecContext &codec_context) noexcept
{
return av_rescale_q(pts, stream.time_base, codec_context.time_base);
}
@@ -437,7 +437,7 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is,
gcc_const
static SampleFormat
ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
{
switch (sample_fmt) {
case AV_SAMPLE_FMT_S16:

View File

@@ -67,7 +67,7 @@ flac_parse_mixramp(const FLAC__StreamMetadata_VorbisComment &vc)
*/
static const char *
flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
const char *name)
const char *name) noexcept
{
return vorbis_comment_value((const char *)entry->entry, name);
}
@@ -126,7 +126,7 @@ flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment,
gcc_pure
static inline SongTime
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info)
flac_duration(const FLAC__StreamMetadata_StreamInfo *stream_info) noexcept
{
assert(stream_info->sample_rate > 0);

View File

@@ -74,7 +74,7 @@ gme_plugin_init(gcc_unused const ConfigBlock &block)
gcc_pure
static unsigned
ParseSubtuneName(const char *base)
ParseSubtuneName(const char *base) noexcept
{
if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0)
return 0;

View File

@@ -71,7 +71,7 @@ static bool gapless_playback;
gcc_const
static SongTime
ToSongTime(mad_timer_t t)
ToSongTime(mad_timer_t t) noexcept
{
return SongTime::FromMS(mad_timer_count(t, MAD_UNITS_MILLISECONDS));
}
@@ -155,10 +155,10 @@ struct MadDecoder {
enum mp3_action DecodeNextFrame();
gcc_pure
offset_type ThisFrameOffset() const;
offset_type ThisFrameOffset() const noexcept;
gcc_pure
offset_type RestIncludingThisFrame() const;
offset_type RestIncludingThisFrame() const noexcept;
/**
* Attempt to calulcate the length of the song from filesize
@@ -177,7 +177,7 @@ struct MadDecoder {
}
gcc_pure
long TimeToFrame(SongTime t) const;
long TimeToFrame(SongTime t) const noexcept;
void UpdateTimerNextFrame();
@@ -291,7 +291,7 @@ parse_id3_replay_gain_info(ReplayGainInfo &rgi,
#ifdef ENABLE_ID3TAG
gcc_pure
static MixRampInfo
parse_id3_mixramp(struct id3_tag *tag)
parse_id3_mixramp(struct id3_tag *tag) noexcept
{
MixRampInfo result;
@@ -710,7 +710,7 @@ mp3_frame_duration(const struct mad_frame *frame)
}
inline offset_type
MadDecoder::ThisFrameOffset() const
MadDecoder::ThisFrameOffset() const noexcept
{
auto offset = input_stream.GetOffset();
@@ -723,7 +723,7 @@ MadDecoder::ThisFrameOffset() const
}
inline offset_type
MadDecoder::RestIncludingThisFrame() const
MadDecoder::RestIncludingThisFrame() const noexcept
{
return input_stream.GetSize() - ThisFrameOffset();
}
@@ -846,7 +846,7 @@ mad_decoder_total_file_time(InputStream &is)
}
long
MadDecoder::TimeToFrame(SongTime t) const
MadDecoder::TimeToFrame(SongTime t) const noexcept
{
unsigned long i;

View File

@@ -31,7 +31,7 @@
gcc_pure
static TagType
ParseOpusTagName(const char *name)
ParseOpusTagName(const char *name) noexcept
{
TagType type = tag_name_parse_i(name);
if (type != TAG_NUM_OF_ITEM_TYPES)

View File

@@ -116,7 +116,7 @@ struct SidplayContainerPath {
gcc_pure
static unsigned
ParseSubtuneName(const char *base)
ParseSubtuneName(const char *base) noexcept
{
if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0)
return 0;
@@ -390,7 +390,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
gcc_pure
static const char *
GetInfoString(const SidTuneInfo &info, unsigned i)
GetInfoString(const SidTuneInfo &info, unsigned i) noexcept
{
#ifdef HAVE_SIDPLAYFP
return info.numberOfInfoStrings() > i

View File

@@ -148,7 +148,7 @@ sndfile_duration(const SF_INFO &info)
gcc_pure
static SampleFormat
sndfile_sample_format(const SF_INFO &info)
sndfile_sample_format(const SF_INFO &info) noexcept
{
switch (info.format & SF_FORMAT_SUBMASK) {
case SF_FORMAT_PCM_S8:

View File

@@ -101,7 +101,7 @@ WavpackOpenInput(WavpackStreamReader *reader, void *wv_id, void *wvc_id,
gcc_pure
static SignedSongTime
GetDuration(WavpackContext *wpc)
GetDuration(WavpackContext *wpc) noexcept
{
#ifdef OPEN_DSD_AS_PCM
/* libWavPack 5 */