]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Tweak code style
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 12 Jul 2023 11:57:07 +0000 (13:57 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 12 Jul 2023 11:57:07 +0000 (13:57 +0200)
src/argprocessing.cpp
src/ccache.cpp
unittest/test_Args.cpp

index 63a432ca6bc17758a9e7bcf89fccf11887bf0095..4651ed95fd74cca51d3781856249b24376628e8a 100644 (file)
@@ -399,15 +399,14 @@ process_option_arg(const Context& ctx,
     config.set_direct_mode(false);
   }
 
-  // -Xarch_* options need to be handled with care
+  // Handle -Xarch_* options.
   if (util::starts_with(arg, "-Xarch_")) {
     if (i == args.size() - 1) {
       LOG("Missing argument to {}", args[i]);
       return Statistic::bad_compiler_arguments;
     }
     const auto arch = arg.substr(7);
-    auto [it, inserted] =
-      state.xarch_args.emplace(arch, std::vector<std::string>());
+    auto it = state.xarch_args.emplace(arch, std::vector<std::string>()).first;
     it->second.emplace_back(args[i + 1]);
     ++i;
     return Statistic::none;
index bc21ea18a7f67aea2524f348fcee6c14fe846309..20bd454bd0a05407d4bcc9af10045fd4f3e0277f 100644 (file)
@@ -2047,7 +2047,7 @@ calculate_result_and_manifest_key(Context& ctx,
     preprocessor_args->push_back("-arch");
     for (size_t i = 0; i < ctx.args_info.arch_args.size(); ++i) {
       const auto& arch = ctx.args_info.arch_args[i];
-      size_t xarch_count{};
+      size_t xarch_count = 0;
       preprocessor_args->push_back(arch);
       auto it = ctx.args_info.xarch_args.find(arch);
       if (it != ctx.args_info.xarch_args.end()) {
@@ -2067,10 +2067,7 @@ calculate_result_and_manifest_key(Context& ctx,
       if (i != ctx.args_info.arch_args.size() - 1) {
         result_key = std::nullopt;
       }
-      preprocessor_args->pop_back();
-      if (xarch_count > 0) {
-        preprocessor_args->pop_back(xarch_count);
-      }
+      preprocessor_args->pop_back(1 + xarch_count);
     }
     preprocessor_args->pop_back();
   }
index 388213fda8be892cba3f1f67086bd89f82ce5d30..82b51ec1520f57839c38db643fabde1b60f95390 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -381,6 +381,9 @@ TEST_CASE("Args operations")
 
   SUBCASE("pop_back")
   {
+    args.pop_back(0);
+    CHECK(args == Args::from_string("eeny meeny miny moe"));
+
     args.pop_back();
     CHECK(args == Args::from_string("eeny meeny miny"));
 
@@ -390,6 +393,9 @@ TEST_CASE("Args operations")
 
   SUBCASE("pop_front")
   {
+    args.pop_front(0);
+    CHECK(args == Args::from_string("eeny meeny miny moe"));
+
     args.pop_front();
     CHECK(args == Args::from_string("meeny miny moe"));