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:
parent
dae0d7bec6
commit
09e77fa146
8 changed files with 76 additions and 89 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue