Commit 97e5ebe4906221ba0666608a842f4e3e28c544ac

Authored by Alex Dewar
Committed by GitHub
1 parent 438eabe5

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

Use a const reference to avoid unnecessary copies. Also constify the
argument to _parse_config.
Showing 1 changed file with 2 additions and 2 deletions
include/CLI/App.hpp
@@ -2390,8 +2390,8 @@ class App { @@ -2390,8 +2390,8 @@ class App {
2390 /// 2390 ///
2391 /// If this has more than one dot.separated.name, go into the subcommand matching it 2391 /// If this has more than one dot.separated.name, go into the subcommand matching it
2392 /// Returns true if it managed to find the option, if false you'll need to remove the arg manually. 2392 /// Returns true if it managed to find the option, if false you'll need to remove the arg manually.
2393 - void _parse_config(std::vector<ConfigItem> &args) {  
2394 - for(ConfigItem item : args) { 2393 + void _parse_config(const std::vector<ConfigItem> &args) {
  2394 + for(const ConfigItem &item : args) {
2395 if(!_parse_single_config(item) && allow_config_extras_ == config_extras_mode::error) 2395 if(!_parse_single_config(item) && allow_config_extras_ == config_extras_mode::error)
2396 throw ConfigError::Extras(item.fullname()); 2396 throw ConfigError::Extras(item.fullname());
2397 } 2397 }