From 223f67c2cbf4648c3aaa907ec0edf98e53b574e9 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 13 Jun 2025 13:14:27 +0200 Subject: Avoid unnecessary work in accessing container entries - in sequence containers, use operator[] instead of .at() when accessing indices guaranteed to be in bound; - in associative containers, prefer .find() and reusing the returned const iterator to using .contains() and .at(); while there, make any so obtained iterators const if they are read-only. --- src/other_tools/just_mr/launch.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/other_tools/just_mr/launch.cpp') diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index 0a061031..c085f5be 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -93,8 +93,9 @@ auto CallJust(std::optional const& config_file, std::optional lock{}; if (subcommand and kKnownJustSubcommands.contains(*subcommand)) { + auto const& flags = kKnownJustSubcommands.at(*subcommand); // Read the config file if needed - if (kKnownJustSubcommands.at(*subcommand).config) { + if (flags.config) { auto repo_lock = RepositoryGarbageCollector::SharedLock(storage_config); if (not repo_lock) { @@ -128,15 +129,14 @@ auto CallJust(std::optional const& config_file, return kExitSetupError; } } - use_build_root = kKnownJustSubcommands.at(*subcommand).build_root; - use_launcher = kKnownJustSubcommands.at(*subcommand).launch; - supports_defines = kKnownJustSubcommands.at(*subcommand).defines; - supports_remote = kKnownJustSubcommands.at(*subcommand).remote; - supports_remote_properties = - kKnownJustSubcommands.at(*subcommand).remote_props; - supports_serve = kKnownJustSubcommands.at(*subcommand).serve; - supports_dispatch = kKnownJustSubcommands.at(*subcommand).dispatch; - does_build = kKnownJustSubcommands.at(*subcommand).does_build; + use_build_root = flags.build_root; + use_launcher = flags.launch; + supports_defines = flags.defines; + supports_remote = flags.remote; + supports_remote_properties = flags.remote_props; + supports_serve = flags.serve; + supports_dispatch = flags.dispatch; + does_build = flags.does_build; } // build just command std::vector cmd = {common_args.just_path->string()}; -- cgit v1.2.3