From 8663a927cd39b5e2ea390991bf87503d15d48cc0 Mon Sep 17 00:00:00 2001 From: Michael Akopyan Date: Thu, 11 Mar 2021 18:13:15 -0800 Subject: [PATCH] remove unnecessary captured variable - move vector lower to where matches is used - auto stuff --- src/client/component/command.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 7d79cc2..8616484 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -257,7 +257,7 @@ namespace command add("consoleList", [](const params& params) { std::string input = params.get(1); - std::vector matches; + // "borrowed" these two functions from game_console auto match_compare = [](const std::string& input, const std::string& text, bool exact) { @@ -266,7 +266,7 @@ namespace command return false; }; - auto find_matches = [&matches, match_compare](std::string& input, std::vector& suggestions, + auto find_matches = [match_compare](std::string& input, std::vector& suggestions, const bool exact) { input = utils::string::to_lower(input); @@ -279,12 +279,12 @@ namespace command if (match_compare(input, name, exact)) { - matches.push_back(game::sortedDvars[i]->name); + suggestions.push_back(game::sortedDvars[i]->name); } } } - game::cmd_function_s* cmd = (*game::cmd_functions); + auto* cmd = (*game::cmd_functions); while (cmd) { if (cmd->name) @@ -305,6 +305,7 @@ namespace command } }; + std::vector matches; find_matches(input, matches, false); for(auto& match : matches)