]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Clean up some fs::path usage
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 8 Jun 2024 18:57:13 +0000 (20:57 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:52 +0000 (17:18 +0200)
src/ccache/argprocessing.cpp
src/ccache/ccache.cpp

index be335d1f3f050e015723bb550ac348bc06e41fe5..8ecd6c5416f72dd8cd168ab70e7b8d93d1fe6e56 100644 (file)
@@ -918,7 +918,7 @@ process_option_arg(const Context& ctx,
     }
     state.common_args.push_back(args[i]);
     auto relpath = core::make_relative_path(ctx, args[i + 1]);
-    state.common_args.push_back(util::pstr(relpath));
+    state.common_args.push_back(relpath);
     i++;
     return Statistic::none;
   }
@@ -1125,7 +1125,7 @@ process_option_arg(const Context& ctx,
     if (next == 2) {
       dest_args.push_back(args[i + 1]);
     }
-    dest_args.push_back(util::pstr(relpath));
+    dest_args.push_back(relpath);
 
     i += next;
     return Statistic::none;
@@ -1595,7 +1595,7 @@ process_args(Context& ctx)
     }
 
     if (!args_info.dependency_target) {
-      std::string dep_target = util::pstr(args_info.orig_output_obj);
+      fs::path dep_target = args_info.orig_output_obj;
 
       // GCC and Clang behave differently when "-Wp,-M[M]D,wp.d" is used with
       // "-o" but with neither "-MMD" nor "-MT"/"-MQ": GCC uses a dependency
@@ -1609,9 +1609,9 @@ process_args(Context& ctx)
         } else if (config.compiler_type() == CompilerType::gcc) {
           // GCC strangely uses the base name of the source file but with a .o
           // extension.
-          dep_target = util::pstr(util::with_extension(
-            args_info.orig_input_file.filename(),
-            get_default_object_file_extension(ctx.config)));
+          dep_target =
+            util::with_extension(args_info.orig_input_file.filename(),
+                                 get_default_object_file_extension(ctx.config));
         } else {
           // How other compilers behave is currently unknown, so bail out.
           LOG_RAW(
@@ -1621,7 +1621,8 @@ process_args(Context& ctx)
         }
       }
 
-      args_info.dependency_target = Depfile::escape_filename(dep_target);
+      args_info.dependency_target =
+        Depfile::escape_filename(util::pstr(dep_target).str());
     }
   }
 
index b5a263910d81e1aeb82810a65ef48bf8534896b2..a250d4c46cad9f9ccbdc8b57d93078a14311bdf4 100644 (file)
@@ -1553,10 +1553,9 @@ hash_common_info(const Context& ctx,
   // even without debug flags. Hashing the directory should be enough since the
   // filename is included in the hash anyway.
   if (ctx.config.is_compiler_group_msvc() && ctx.config.hash_dir()) {
-    const std::string output_obj_dir =
-      args_info.output_obj.is_absolute()
-        ? args_info.output_obj.parent_path().string()
-        : util::pstr(ctx.actual_cwd);
+    const fs::path& output_obj_dir = args_info.output_obj.is_absolute()
+                                       ? args_info.output_obj.parent_path()
+                                       : ctx.actual_cwd;
     LOG("Hashing object file directory {}", output_obj_dir);
     hash.hash_delimiter("source path");
     hash.hash(output_obj_dir);