*: 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

@@ -68,7 +68,7 @@ ConfigBlock::~ConfigBlock()
}
const BlockParam *
ConfigBlock::GetBlockParam(const char *name) const
ConfigBlock::GetBlockParam(const char *name) const noexcept
{
for (const auto &i : block_params) {
if (i.name == name) {
@@ -81,7 +81,8 @@ ConfigBlock::GetBlockParam(const char *name) const
}
const char *
ConfigBlock::GetBlockValue(const char *name, const char *default_value) const
ConfigBlock::GetBlockValue(const char *name,
const char *default_value) const noexcept
{
const BlockParam *bp = GetBlockParam(name);
if (bp == nullptr)

View File

@@ -101,11 +101,11 @@ struct ConfigBlock {
}
gcc_nonnull_all gcc_pure
const BlockParam *GetBlockParam(const char *_name) const;
const BlockParam *GetBlockParam(const char *_name) const noexcept;
gcc_pure
const char *GetBlockValue(const char *name,
const char *default_value=nullptr) const;
const char *default_value=nullptr) const noexcept;
/**
* Same as config_get_path(), but looks up the setting in the

View File

@@ -75,7 +75,7 @@ void config_global_check(void)
}
const ConfigParam *
config_get_param(ConfigOption option)
config_get_param(ConfigOption option) noexcept
{
auto *param = config_data.params[unsigned(option)];
if (param != nullptr)
@@ -84,7 +84,7 @@ config_get_param(ConfigOption option)
}
const ConfigBlock *
config_get_block(ConfigBlockOption option)
config_get_block(ConfigBlockOption option) noexcept
{
ConfigBlock *block = config_data.blocks[unsigned(option)];
if (block != nullptr)
@@ -110,7 +110,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value)
}
const char *
config_get_string(ConfigOption option, const char *default_value)
config_get_string(ConfigOption option, const char *default_value) noexcept
{
const auto *param = config_get_param(option);

View File

@@ -48,11 +48,11 @@ ReadConfigFile(Path path);
gcc_pure
const ConfigParam *
config_get_param(enum ConfigOption option);
config_get_param(enum ConfigOption option) noexcept;
gcc_pure
const ConfigBlock *
config_get_block(enum ConfigBlockOption option);
config_get_block(enum ConfigBlockOption option) noexcept;
/**
* Find a block with a matching attribute.
@@ -74,7 +74,8 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value);
gcc_pure
const char *
config_get_string(enum ConfigOption option, const char *default_value=nullptr);
config_get_string(enum ConfigOption option,
const char *default_value=nullptr) noexcept;
/**
* Returns an optional configuration variable which contains an

View File

@@ -102,13 +102,13 @@ enum class ConfigBlockOption {
*/
gcc_pure
enum ConfigOption
ParseConfigOptionName(const char *name);
ParseConfigOptionName(const char *name) noexcept;
/**
* @return #ConfigOption::MAX if not found
*/
gcc_pure
enum ConfigBlockOption
ParseConfigBlockOptionName(const char *name);
ParseConfigBlockOptionName(const char *name) noexcept;
#endif

View File

@@ -101,7 +101,7 @@ static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX),
gcc_pure
static inline unsigned
ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
const char *name)
const char *name) noexcept
{
unsigned i = 0;
for (; i < count; ++i)
@@ -112,7 +112,7 @@ ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
}
ConfigOption
ParseConfigOptionName(const char *name)
ParseConfigOptionName(const char *name) noexcept
{
return ConfigOption(ParseConfigTemplateName(config_param_templates,
n_config_param_templates,
@@ -120,7 +120,7 @@ ParseConfigOptionName(const char *name)
}
ConfigBlockOption
ParseConfigBlockOptionName(const char *name)
ParseConfigBlockOptionName(const char *name) noexcept
{
return ConfigBlockOption(ParseConfigTemplateName(config_block_templates,
n_config_block_templates,