From 97e5ebe4906221ba0666608a842f4e3e28c544ac Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Fri, 16 Oct 2020 02:51:21 +0100 Subject: [PATCH] fix: don't copy ConfigItems when iterating (#521) Use a const reference to avoid unnecessary copies. Also constify the argument to _parse_config. --- include/CLI/App.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 94f05c85..fc31de8f 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -2390,8 +2390,8 @@ class App { /// /// 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. - void _parse_config(std::vector &args) { - for(ConfigItem item : args) { + void _parse_config(const std::vector &args) { + for(const ConfigItem &item : args) { if(!_parse_single_config(item) && allow_config_extras_ == config_extras_mode::error) throw ConfigError::Extras(item.fullname()); }