From: Joel Rosdahl Date: Sat, 1 Jun 2024 11:01:23 +0000 (+0200) Subject: refactor: Improve language_for_file signature X-Git-Tag: v4.11~129 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c7848bbfd0a0e6311f4af4aea2ceefe6efc18890;p=thirdparty%2Fccache.git refactor: Improve language_for_file signature --- diff --git a/src/ccache/language.cpp b/src/ccache/language.cpp index 66522de0..41db79a4 100644 --- a/src/ccache/language.cpp +++ b/src/ccache/language.cpp @@ -104,10 +104,10 @@ const struct } // namespace -std::string -language_for_file(const std::string& fname, CompilerType compiler_type) +std::string_view +language_for_file(const fs::path& path, CompilerType compiler_type) { - const auto ext = fs::path(fname).extension(); + const auto ext = path.extension(); if (ext == ".cu" && compiler_type == CompilerType::clang) { // Special case: Clang maps .cu to cuda. return "cuda"; diff --git a/src/ccache/language.hpp b/src/ccache/language.hpp index 1ab0f977..c58f1aa2 100644 --- a/src/ccache/language.hpp +++ b/src/ccache/language.hpp @@ -20,12 +20,14 @@ #include +#include #include +#include -// Guess the language of `fname` based on its extension and a compiler type. +// Guess the language of `path` based on its extension and a compiler type. // Returns the empty string if the extension is unknown. -std::string language_for_file(const std::string& fname, - CompilerType compiler_type); +std::string_view language_for_file(const std::filesystem::path& path, + CompilerType compiler_type); // Return the preprocessed language for `language`, or the empty string if // unknown.