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)