]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Refactor logical expression in find_compiler
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 11 Oct 2020 12:39:34 +0000 (14:39 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 12 Oct 2020 19:18:34 +0000 (21:18 +0200)
src/ccache.cpp

index b371c65eb6affb1beca0916b44e2f4f4cdcca4d5..0a3a089ebda8140a51a8758523850834eebcd3ce 100644 (file)
@@ -1828,20 +1828,18 @@ void
 find_compiler(Context& ctx,
               const FindExecutableFunction& find_executable_function)
 {
+  const nonstd::string_view first_param_base_name =
+    Util::base_name(ctx.orig_args[0]);
   const bool first_param_is_ccache =
-    Util::same_program_name(Util::base_name(ctx.orig_args[0]), CCACHE_NAME);
+    Util::same_program_name(first_param_base_name, CCACHE_NAME);
 
   // Support user override of the compiler.
-  const std::string compiler = [&] {
-    if (!ctx.config.compiler().empty()) {
-      return ctx.config.compiler();
-    } else if (first_param_is_ccache) {
-      return ctx.orig_args[1];
-    } else {
-      // ccache is masquerading as compiler
-      return std::string(Util::base_name(ctx.orig_args[0]));
-    }
-  }();
+  const std::string compiler =
+    !ctx.config.compiler().empty()
+      ? ctx.config.compiler()
+      : (first_param_is_ccache ? ctx.orig_args[1]
+                               // ccache is masquerading as compiler:
+                               : std::string(first_param_base_name));
 
   const std::string resolved_compiler =
     Util::is_full_path(compiler)