1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-02 21:53:51 +00:00

fix: don't copy ConfigItems when iterating (#521)

Use a const reference to avoid unnecessary copies. Also constify the
argument to _parse_config.
This commit is contained in:
Alex Dewar 2020-10-16 02:51:21 +01:00 committed by GitHub
parent 438eabe5f8
commit 97e5ebe490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2390,8 +2390,8 @@ class App {
/// ///
/// If this has more than one dot.separated.name, go into the subcommand matching it /// If this has more than one dot.separated.name, go into the subcommand matching it
/// Returns true if it managed to find the option, if false you'll need to remove the arg manually. /// Returns true if it managed to find the option, if false you'll need to remove the arg manually.
void _parse_config(std::vector<ConfigItem> &args) { void _parse_config(const std::vector<ConfigItem> &args) {
for(ConfigItem item : args) { for(const ConfigItem &item : args) {
if(!_parse_single_config(item) && allow_config_extras_ == config_extras_mode::error) if(!_parse_single_config(item) && allow_config_extras_ == config_extras_mode::error)
throw ConfigError::Extras(item.fullname()); throw ConfigError::Extras(item.fullname());
} }