1
0
Fork 0
forked from eden-emu/eden

[common, fs] Use std::string_view instead of std::string&; inline functions that are used rarely (#330)

Signed-off-by: lizzie <lizzie@eden-emu.dev>
Co-authored-by: crueter <crueter@eden-emu.dev>
Reviewed-on: eden-emu/eden#330
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-08-27 22:21:04 +02:00 committed by crueter
parent dae0d7bec6
commit 09e77fa146
Signed by untrusted user: crueter
GPG key ID: 425ACD2D4830EBC6
8 changed files with 76 additions and 89 deletions

View file

@ -352,9 +352,17 @@ enum class DirectorySeparator {
[[nodiscard]] std::string_view GetPathWithoutTop(std::string_view path);
// Gets the filename of the path
[[nodiscard]] std::string_view GetFilename(std::string_view path);
[[nodiscard]] inline std::string_view GetFilename(const std::string_view path) noexcept {
if (auto const name_index = path.find_last_of("\\/"); name_index != std::string_view::npos)
return path.substr(name_index + 1);
return {};
}
// Gets the extension of the filename
[[nodiscard]] std::string_view GetExtensionFromFilename(std::string_view name);
[[nodiscard]] inline std::string_view GetExtensionFromFilename(const std::string_view name) noexcept {
if (auto const index = name.rfind('.'); index != std::string_view::npos)
return name.substr(index + 1);
return {};
}
} // namespace Common::FS