From: Joel Rosdahl Date: Tue, 28 Jan 2020 18:47:36 +0000 (+0100) Subject: Simplify code a bit X-Git-Tag: v4.0~659 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=997f90b942f7a9ca42f77695afbadefb0f8c3d99;p=thirdparty%2Fccache.git Simplify code a bit --- diff --git a/src/ccache.cpp b/src/ccache.cpp index 96f8fd81d..f9ac18284 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -631,12 +631,9 @@ print_included_files(FILE* fp) static std::string make_relative_path(const char* path) { - std::string result; - if (g_config.base_dir().empty() || !str_startswith(path, g_config.base_dir().c_str())) { - result = path; - return result; + return path; } #ifdef _WIN32 @@ -681,6 +678,8 @@ make_relative_path(const char* path) path = dir; } + std::string result; + canon_path = x_realpath(path); if (canon_path) { relpath = get_relative_path(get_current_working_dir(), canon_path); @@ -1018,7 +1017,7 @@ result_name_from_depfile(const char* depfile, struct hash* hash) if (!has_absolute_include_headers) { has_absolute_include_headers = is_absolute_path(token); } - std::string path = make_relative_path(token).c_str(); + std::string path = make_relative_path(token); remember_include_file(path, hash, false, hash); } } @@ -3167,10 +3166,8 @@ cc_process_args(ArgsInfo& args_info, args_info.output_obj = args_info.input_file + ".gch"; } else { string_view extension = found_S_opt ? ".s" : ".o"; - args_info.output_obj = std::string(Util::base_name(args_info.input_file)); - - args_info.output_obj = - Util::change_extension(args_info.output_obj, extension); + args_info.output_obj = Util::change_extension( + Util::base_name(args_info.input_file), extension); } }