From: Joel Rosdahl Date: Sun, 11 Oct 2020 12:39:34 +0000 (+0200) Subject: Refactor logical expression in find_compiler X-Git-Tag: v4.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb8aec827b5d2c054e6c940284fdeed87df88106;p=thirdparty%2Fccache.git Refactor logical expression in find_compiler --- diff --git a/src/ccache.cpp b/src/ccache.cpp index b371c65eb..0a3a089eb 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -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)