From 12a06443155579099d1e935486e43c0592b12b48 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 15 May 2024 09:42:40 +1000 Subject: [PATCH] Misc: Pass most string_views by value instead of reference --- common/FileSystem.cpp | 46 +++++++++---------- common/FileSystem.h | 2 +- common/Image.cpp | 2 +- common/Path.h | 42 ++++++++--------- common/StringUtil.cpp | 28 +++++------ common/StringUtil.h | 46 +++++++++---------- pcsx2-gsrunner/Main.cpp | 36 ++++++--------- pcsx2-qt/QtHost.cpp | 27 +++++------ pcsx2-qt/QtKeyCodes.cpp | 2 +- pcsx2-qt/QtUtils.cpp | 2 +- pcsx2-qt/QtUtils.h | 2 +- pcsx2-qt/Settings/GameCheatSettingsWidget.cpp | 2 +- pcsx2-qt/Settings/GameCheatSettingsWidget.h | 2 +- pcsx2-qt/Settings/SettingsWindow.cpp | 2 +- pcsx2-qt/Settings/SettingsWindow.h | 2 +- pcsx2-qt/Translations.cpp | 10 ++-- pcsx2/Achievements.cpp | 8 ++-- pcsx2/CDVD/CDVD.cpp | 6 +-- pcsx2/CDVD/CDVD.h | 4 +- pcsx2/CDVD/IsoReader.cpp | 14 +++--- pcsx2/CDVD/IsoReader.h | 14 +++--- pcsx2/Config.h | 2 +- pcsx2/GS/GS.h | 6 +-- pcsx2/GS/Renderers/DX11/D3D.cpp | 8 ++-- pcsx2/GS/Renderers/DX11/D3D.h | 8 ++-- pcsx2/GS/Renderers/DX11/D3D11ShaderCache.cpp | 14 +++--- pcsx2/GS/Renderers/DX11/D3D11ShaderCache.h | 14 +++--- pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp | 4 +- pcsx2/GS/Renderers/DX12/D3D12ShaderCache.h | 4 +- pcsx2/GS/Renderers/HW/GSHwHack.cpp | 6 +-- .../HW/GSTextureReplacementLoaders.cpp | 2 +- pcsx2/GS/Renderers/HW/GSTextureReplacements.h | 2 +- pcsx2/GS/Renderers/OpenGL/GLProgram.cpp | 2 +- pcsx2/GS/Renderers/OpenGL/GLProgram.h | 2 +- pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp | 12 ++--- pcsx2/GS/Renderers/OpenGL/GLShaderCache.h | 14 +++--- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 4 +- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h | 6 +-- pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp | 2 +- pcsx2/GS/Renderers/Vulkan/VKShaderCache.h | 2 +- pcsx2/GameDatabase.cpp | 12 ++--- pcsx2/GameDatabase.h | 4 +- pcsx2/GameList.cpp | 10 ++-- pcsx2/GameList.h | 2 +- pcsx2/Host.cpp | 14 +++--- pcsx2/Host.h | 22 ++++----- pcsx2/ImGui/FullscreenUI.cpp | 24 +++++----- pcsx2/ImGui/ImGuiFullscreen.h | 2 +- pcsx2/ImGui/ImGuiManager.cpp | 2 +- pcsx2/Input/DInputSource.cpp | 4 +- pcsx2/Input/DInputSource.h | 4 +- pcsx2/Input/InputManager.cpp | 34 +++++++------- pcsx2/Input/InputManager.h | 10 ++-- pcsx2/Input/InputSource.cpp | 2 +- pcsx2/Input/InputSource.h | 6 +-- pcsx2/Input/SDLInputSource.cpp | 22 ++++----- pcsx2/Input/SDLInputSource.h | 8 ++-- pcsx2/Input/XInputSource.cpp | 14 +++--- pcsx2/Input/XInputSource.h | 4 +- pcsx2/Patch.cpp | 40 ++++++++-------- pcsx2/Patch.h | 4 +- pcsx2/Pcsx2Config.cpp | 2 +- pcsx2/SIO/Memcard/MemoryCardFile.cpp | 8 ++-- pcsx2/SIO/Memcard/MemoryCardFile.h | 9 ++-- pcsx2/SIO/Memcard/MemoryCardFolder.cpp | 14 +++--- pcsx2/SIO/Memcard/MemoryCardFolder.h | 12 ++--- pcsx2/SIO/Pad/Pad.cpp | 4 +- pcsx2/SIO/Pad/Pad.h | 2 +- pcsx2/SIO/Pad/PadTypes.h | 2 +- pcsx2/USB/USB.cpp | 22 ++++----- pcsx2/USB/USB.h | 22 ++++----- pcsx2/USB/deviceproxy.cpp | 4 +- pcsx2/USB/deviceproxy.h | 8 ++-- pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp | 4 +- pcsx2/USB/usb-pad/usb-pad-sdl-ff.h | 4 +- pcsx2/USB/usb-pad/usb-pad.cpp | 4 +- pcsx2/USB/usb-pad/usb-pad.h | 4 +- pcsx2/VMManager.cpp | 20 ++++---- pcsx2/VMManager.h | 24 +++++----- tests/ctest/core/StubHost.cpp | 18 ++++---- 80 files changed, 415 insertions(+), 429 deletions(-) diff --git a/common/FileSystem.cpp b/common/FileSystem.cpp index 437f23e8dc..b79cdd224d 100644 --- a/common/FileSystem.cpp +++ b/common/FileSystem.cpp @@ -137,7 +137,7 @@ static inline void PathAppendString(std::string& dst, const T& src) } } -std::string Path::SanitizeFileName(const std::string_view& str, bool strip_slashes /* = true */) +std::string Path::SanitizeFileName(const std::string_view str, bool strip_slashes /* = true */) { std::string ret; ret.reserve(str.length()); @@ -191,7 +191,7 @@ void Path::SanitizeFileName(std::string* str, bool strip_slashes /* = true */) #endif } -bool Path::IsValidFileName(const std::string_view& str, bool allow_slashes) +bool Path::IsValidFileName(const std::string_view str, bool allow_slashes) { const size_t len = str.length(); size_t pos = 0; @@ -272,7 +272,7 @@ std::wstring FileSystem::GetWin32Path(std::string_view str) #endif -bool Path::IsAbsolute(const std::string_view& path) +bool Path::IsAbsolute(const std::string_view path) { #ifdef _WIN32 return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) && @@ -283,7 +283,7 @@ bool Path::IsAbsolute(const std::string_view& path) #endif } -std::string Path::RealPath(const std::string_view& path) +std::string Path::RealPath(const std::string_view path) { // Resolve non-absolute paths first. std::vector components; @@ -457,7 +457,7 @@ std::string Path::RealPath(const std::string_view& path) return realpath; } -std::string Path::ToNativePath(const std::string_view& path) +std::string Path::ToNativePath(const std::string_view path) { std::string ret; PathAppendString(ret, path); @@ -477,7 +477,7 @@ void Path::ToNativePath(std::string* path) *path = Path::ToNativePath(*path); } -std::string Path::Canonicalize(const std::string_view& path) +std::string Path::Canonicalize(const std::string_view path) { std::vector components = Path::SplitNativePath(path); std::vector new_components; @@ -513,7 +513,7 @@ void Path::Canonicalize(std::string* path) *path = Canonicalize(*path); } -std::string Path::MakeRelative(const std::string_view& path, const std::string_view& relative_to) +std::string Path::MakeRelative(const std::string_view path, const std::string_view relative_to) { // simple algorithm, we just work on the components. could probably be better, but it'll do for now. std::vector path_components(SplitNativePath(path)); @@ -560,7 +560,7 @@ std::string Path::MakeRelative(const std::string_view& path, const std::string_v return JoinNativePath(new_components); } -std::string_view Path::GetExtension(const std::string_view& path) +std::string_view Path::GetExtension(const std::string_view path) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -569,7 +569,7 @@ std::string_view Path::GetExtension(const std::string_view& path) return path.substr(pos + 1); } -std::string_view Path::StripExtension(const std::string_view& path) +std::string_view Path::StripExtension(const std::string_view path) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -578,7 +578,7 @@ std::string_view Path::StripExtension(const std::string_view& path) return path.substr(0, pos); } -std::string Path::ReplaceExtension(const std::string_view& path, const std::string_view& new_extension) +std::string Path::ReplaceExtension(const std::string_view path, const std::string_view new_extension) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -589,7 +589,7 @@ std::string Path::ReplaceExtension(const std::string_view& path, const std::stri return ret; } -static std::string_view::size_type GetLastSeperatorPosition(const std::string_view& filename, bool include_separator) +static std::string_view::size_type GetLastSeperatorPosition(const std::string_view filename, bool include_separator) { std::string_view::size_type last_separator = filename.rfind('/'); if (include_separator && last_separator != std::string_view::npos) @@ -609,7 +609,7 @@ static std::string_view::size_type GetLastSeperatorPosition(const std::string_vi return last_separator; } -std::string_view Path::GetDirectory(const std::string_view& path) +std::string_view Path::GetDirectory(const std::string_view path) { const std::string::size_type pos = GetLastSeperatorPosition(path, false); if (pos == std::string_view::npos) @@ -618,7 +618,7 @@ std::string_view Path::GetDirectory(const std::string_view& path) return path.substr(0, pos); } -std::string_view Path::GetFileName(const std::string_view& path) +std::string_view Path::GetFileName(const std::string_view path) { const std::string_view::size_type pos = GetLastSeperatorPosition(path, true); if (pos == std::string_view::npos) @@ -627,7 +627,7 @@ std::string_view Path::GetFileName(const std::string_view& path) return path.substr(pos); } -std::string_view Path::GetFileTitle(const std::string_view& path) +std::string_view Path::GetFileTitle(const std::string_view path) { const std::string_view filename(GetFileName(path)); const std::string::size_type pos = filename.rfind('.'); @@ -637,7 +637,7 @@ std::string_view Path::GetFileTitle(const std::string_view& path) return filename.substr(0, pos); } -std::string Path::ChangeFileName(const std::string_view& path, const std::string_view& new_filename) +std::string Path::ChangeFileName(const std::string_view path, const std::string_view new_filename) { std::string ret; PathAppendString(ret, path); @@ -664,12 +664,12 @@ std::string Path::ChangeFileName(const std::string_view& path, const std::string return ret; } -void Path::ChangeFileName(std::string* path, const std::string_view& new_filename) +void Path::ChangeFileName(std::string* path, const std::string_view new_filename) { *path = ChangeFileName(*path, new_filename); } -std::string Path::AppendDirectory(const std::string_view& path, const std::string_view& new_dir) +std::string Path::AppendDirectory(const std::string_view path, const std::string_view new_dir) { std::string ret; if (!new_dir.empty()) @@ -711,12 +711,12 @@ std::string Path::AppendDirectory(const std::string_view& path, const std::strin return ret; } -void Path::AppendDirectory(std::string* path, const std::string_view& new_dir) +void Path::AppendDirectory(std::string* path, const std::string_view new_dir) { *path = AppendDirectory(*path, new_dir); } -std::vector Path::SplitWindowsPath(const std::string_view& path) +std::vector Path::SplitWindowsPath(const std::string_view path) { std::vector parts; @@ -754,7 +754,7 @@ std::string Path::JoinWindowsPath(const std::vector& component return StringUtil::JoinString(components.begin(), components.end(), '\\'); } -std::vector Path::SplitNativePath(const std::string_view& path) +std::vector Path::SplitNativePath(const std::string_view path) { #ifdef _WIN32 return SplitWindowsPath(path); @@ -821,7 +821,7 @@ std::vector FileSystem::GetRootDirectoryList() return results; } -std::string Path::BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename) +std::string Path::BuildRelativePath(const std::string_view filename, const std::string_view new_filename) { std::string new_string; @@ -832,7 +832,7 @@ std::string Path::BuildRelativePath(const std::string_view& filename, const std: return new_string; } -std::string Path::Combine(const std::string_view& base, const std::string_view& next) +std::string Path::Combine(const std::string_view base, const std::string_view next) { std::string ret; ret.reserve(base.length() + next.length() + 1); @@ -1171,7 +1171,7 @@ bool FileSystem::WriteBinaryFile(const char* filename, const void* data, size_t return true; } -bool FileSystem::WriteStringToFile(const char* filename, const std::string_view& sv) +bool FileSystem::WriteStringToFile(const char* filename, const std::string_view sv) { ManagedCFilePtr fp = OpenManagedCFile(filename, "wb"); if (!fp) diff --git a/common/FileSystem.h b/common/FileSystem.h index e77c46ab3d..4edfb58489 100644 --- a/common/FileSystem.h +++ b/common/FileSystem.h @@ -130,7 +130,7 @@ namespace FileSystem std::optional ReadFileToString(const char* filename); std::optional ReadFileToString(std::FILE* fp); bool WriteBinaryFile(const char* filename, const void* data, size_t data_length); - bool WriteStringToFile(const char* filename, const std::string_view& sv); + bool WriteStringToFile(const char* filename, const std::string_view sv); /// creates a directory in the local filesystem /// if the directory already exists, the return value will be true. diff --git a/common/Image.cpp b/common/Image.cpp index caef8f59ab..a635170ed5 100644 --- a/common/Image.cpp +++ b/common/Image.cpp @@ -47,7 +47,7 @@ static constexpr FormatHandler s_format_handlers[] = { {"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver}, }; -static const FormatHandler* GetFormatHandler(const std::string_view& extension) +static const FormatHandler* GetFormatHandler(const std::string_view extension) { for (const FormatHandler& handler : s_format_handlers) { diff --git a/common/Path.h b/common/Path.h index 7e89014465..ee94290989 100644 --- a/common/Path.h +++ b/common/Path.h @@ -12,68 +12,68 @@ namespace Path { /// Converts any forward slashes to backslashes on Win32. - std::string ToNativePath(const std::string_view& path); + std::string ToNativePath(const std::string_view path); void ToNativePath(std::string* path); /// Builds a path relative to the specified file - std::string BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename); + std::string BuildRelativePath(const std::string_view filename, const std::string_view new_filename); /// Joins path components together, producing a new path. - std::string Combine(const std::string_view& base, const std::string_view& next); + std::string Combine(const std::string_view base, const std::string_view next); /// Removes all .. and . components from a path. - std::string Canonicalize(const std::string_view& path); + std::string Canonicalize(const std::string_view path); void Canonicalize(std::string* path); /// Sanitizes a filename for use in a filesystem. - std::string SanitizeFileName(const std::string_view& str, bool strip_slashes = true); + std::string SanitizeFileName(const std::string_view str, bool strip_slashes = true); void SanitizeFileName(std::string* str, bool strip_slashes = true); /// Returns true if the specified filename is valid on this operating system. - bool IsValidFileName(const std::string_view& str, bool allow_slashes = false); + bool IsValidFileName(const std::string_view str, bool allow_slashes = false); /// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix). - bool IsAbsolute(const std::string_view& path); + bool IsAbsolute(const std::string_view path); /// Resolves any symbolic links in the specified path. - std::string RealPath(const std::string_view& path); + std::string RealPath(const std::string_view path); /// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c). /// Both paths must be relative, otherwise this function will just return the input path. - std::string MakeRelative(const std::string_view& path, const std::string_view& relative_to); + std::string MakeRelative(const std::string_view path, const std::string_view relative_to); /// Returns a view of the extension of a filename. - std::string_view GetExtension(const std::string_view& path); + std::string_view GetExtension(const std::string_view path); /// Removes the extension of a filename. - std::string_view StripExtension(const std::string_view& path); + std::string_view StripExtension(const std::string_view path); /// Replaces the extension of a filename with another. - std::string ReplaceExtension(const std::string_view& path, const std::string_view& new_extension); + std::string ReplaceExtension(const std::string_view path, const std::string_view new_extension); /// Returns the directory component of a filename. - std::string_view GetDirectory(const std::string_view& path); + std::string_view GetDirectory(const std::string_view path); /// Returns the filename component of a filename. - std::string_view GetFileName(const std::string_view& path); + std::string_view GetFileName(const std::string_view path); /// Returns the file title (less the extension and path) from a filename. - std::string_view GetFileTitle(const std::string_view& path); + std::string_view GetFileTitle(const std::string_view path); /// Changes the filename in a path. - std::string ChangeFileName(const std::string_view& path, const std::string_view& new_filename); - void ChangeFileName(std::string* path, const std::string_view& new_filename); + std::string ChangeFileName(const std::string_view path, const std::string_view new_filename); + void ChangeFileName(std::string* path, const std::string_view new_filename); /// Appends a directory to a path. - std::string AppendDirectory(const std::string_view& path, const std::string_view& new_dir); - void AppendDirectory(std::string* path, const std::string_view& new_dir); + std::string AppendDirectory(const std::string_view path, const std::string_view new_dir); + void AppendDirectory(std::string* path, const std::string_view new_dir); /// Splits a path into its components, handling both Windows and Unix separators. - std::vector SplitWindowsPath(const std::string_view& path); + std::vector SplitWindowsPath(const std::string_view path); std::string JoinWindowsPath(const std::vector& components); /// Splits a path into its components, only handling native separators. - std::vector SplitNativePath(const std::string_view& path); + std::vector SplitNativePath(const std::string_view path); std::string JoinNativePath(const std::vector& components); /// URL encodes the specified string. diff --git a/common/StringUtil.cpp b/common/StringUtil.cpp index 6b400990a8..aeac44acd3 100644 --- a/common/StringUtil.cpp +++ b/common/StringUtil.cpp @@ -162,7 +162,7 @@ namespace StringUtil return len; } - std::size_t Strlcpy(char* dst, const std::string_view& src, std::size_t size) + std::size_t Strlcpy(char* dst, const std::string_view src, std::size_t size) { std::size_t len = src.length(); if (len < size) @@ -178,7 +178,7 @@ namespace StringUtil return len; } - std::optional> DecodeHex(const std::string_view& in) + std::optional> DecodeHex(const std::string_view in) { std::vector data; data.reserve(in.size() / 2); @@ -204,7 +204,7 @@ namespace StringUtil return ss.str(); } - std::string toLower(const std::string_view& input) + std::string toLower(const std::string_view input) { std::string newStr; std::transform(input.begin(), input.end(), std::back_inserter(newStr), @@ -212,7 +212,7 @@ namespace StringUtil return newStr; } - std::string toUpper(const std::string_view& input) + std::string toUpper(const std::string_view input) { std::string newStr; std::transform(input.begin(), input.end(), std::back_inserter(newStr), @@ -220,7 +220,7 @@ namespace StringUtil return newStr; } - bool compareNoCase(const std::string_view& str1, const std::string_view& str2) + bool compareNoCase(const std::string_view str1, const std::string_view str2) { if (str1.length() != str2.length()) { @@ -241,7 +241,7 @@ namespace StringUtil return lines; } - std::string_view StripWhitespace(const std::string_view& str) + std::string_view StripWhitespace(const std::string_view str) { std::string_view::size_type start = 0; while (start < str.size() && std::isspace(str[start])) @@ -277,7 +277,7 @@ namespace StringUtil } } - std::vector SplitString(const std::string_view& str, char delimiter, bool skip_empty /*= true*/) + std::vector SplitString(const std::string_view str, char delimiter, bool skip_empty /*= true*/) { std::vector res; std::string_view::size_type last_pos = 0; @@ -301,14 +301,14 @@ namespace StringUtil return res; } - std::string ReplaceAll(const std::string_view& subject, const std::string_view& search, const std::string_view& replacement) + std::string ReplaceAll(const std::string_view subject, const std::string_view search, const std::string_view replacement) { std::string ret(subject); ReplaceAll(&ret, search, replacement); return ret; } - void ReplaceAll(std::string* subject, const std::string_view& search, const std::string_view& replacement) + void ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement) { if (!subject->empty()) { @@ -321,7 +321,7 @@ namespace StringUtil } } - bool ParseAssignmentString(const std::string_view& str, std::string_view* key, std::string_view* value) + bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value) { const std::string_view::size_type pos = str.find('='); if (pos == std::string_view::npos) @@ -431,7 +431,7 @@ namespace StringUtil return 1; } - size_t DecodeUTF8(const std::string_view& str, size_t offset, char32_t* ch) + size_t DecodeUTF8(const std::string_view str, size_t offset, char32_t* ch) { return DecodeUTF8(str.data() + offset, str.length() - offset, ch); } @@ -441,7 +441,7 @@ namespace StringUtil return DecodeUTF8(str.data() + offset, str.length() - offset, ch); } - std::string Ellipsise(const std::string_view& str, u32 max_length, const char* ellipsis /*= "..."*/) + std::string Ellipsise(const std::string_view str, u32 max_length, const char* ellipsis /*= "..."*/) { std::string ret; ret.reserve(max_length); @@ -483,7 +483,7 @@ namespace StringUtil } #ifdef _WIN32 - std::wstring UTF8StringToWideString(const std::string_view& str) + std::wstring UTF8StringToWideString(const std::string_view str) { std::wstring ret; if (!UTF8StringToWideString(ret, str)) @@ -492,7 +492,7 @@ namespace StringUtil return ret; } - bool UTF8StringToWideString(std::wstring& dest, const std::string_view& str) + bool UTF8StringToWideString(std::wstring& dest, const std::string_view str) { int wlen = MultiByteToWideChar(CP_UTF8, 0, str.data(), static_cast(str.length()), nullptr, 0); if (wlen < 0) diff --git a/common/StringUtil.h b/common/StringUtil.h index 438a16488f..1e9177f922 100644 --- a/common/StringUtil.h +++ b/common/StringUtil.h @@ -52,7 +52,7 @@ namespace StringUtil std::size_t Strlcpy(char* dst, const char* src, std::size_t size); /// Strlcpy from string_view. - std::size_t Strlcpy(char* dst, const std::string_view& src, std::size_t size); + std::size_t Strlcpy(char* dst, const std::string_view src, std::size_t size); /// Platform-independent strcasecmp static inline int Strcasecmp(const char* s1, const char* s2) @@ -76,7 +76,7 @@ namespace StringUtil /// Wrapper around std::from_chars template ::value, bool> = true> - inline std::optional FromChars(const std::string_view& str, int base = 10) + inline std::optional FromChars(const std::string_view str, int base = 10) { T value; @@ -87,7 +87,7 @@ namespace StringUtil return value; } template ::value, bool> = true> - inline std::optional FromChars(const std::string_view& str, int base, std::string_view* endptr) + inline std::optional FromChars(const std::string_view str, int base, std::string_view* endptr) { T value; @@ -104,7 +104,7 @@ namespace StringUtil } template ::value, bool> = true> - inline std::optional FromChars(const std::string_view& str) + inline std::optional FromChars(const std::string_view str) { T value; @@ -115,7 +115,7 @@ namespace StringUtil return value; } template ::value, bool> = true> - inline std::optional FromChars(const std::string_view& str, std::string_view* endptr) + inline std::optional FromChars(const std::string_view str, std::string_view* endptr) { T value; @@ -177,7 +177,7 @@ namespace StringUtil /// Explicit override for booleans template <> - inline std::optional FromChars(const std::string_view& str, int base) + inline std::optional FromChars(const std::string_view str, int base) { if (Strncasecmp("true", str.data(), str.length()) == 0 || Strncasecmp("yes", str.data(), str.length()) == 0 || Strncasecmp("on", str.data(), str.length()) == 0 || Strncasecmp("1", str.data(), str.length()) == 0 || @@ -203,26 +203,26 @@ namespace StringUtil } /// Encode/decode hexadecimal byte buffers - std::optional> DecodeHex(const std::string_view& str); + std::optional> DecodeHex(const std::string_view str); std::string EncodeHex(const u8* data, int length); /// StartsWith/EndsWith variants which aren't case sensitive. - static inline bool StartsWithNoCase(const std::string_view& str, const std::string_view& prefix) + static inline bool StartsWithNoCase(const std::string_view str, const std::string_view prefix) { return (!str.empty() && Strncasecmp(str.data(), prefix.data(), prefix.length()) == 0); } - static inline bool EndsWithNoCase(const std::string_view& str, const std::string_view& suffix) + static inline bool EndsWithNoCase(const std::string_view str, const std::string_view suffix) { const std::size_t suffix_length = suffix.length(); return (str.length() >= suffix_length && Strncasecmp(str.data() + (str.length() - suffix_length), suffix.data(), suffix_length) == 0); } /// Strip whitespace from the start/end of the string. - std::string_view StripWhitespace(const std::string_view& str); + std::string_view StripWhitespace(const std::string_view str); void StripWhitespace(std::string* str); /// Splits a string based on a single character delimiter. - std::vector SplitString(const std::string_view& str, char delimiter, bool skip_empty = true); + std::vector SplitString(const std::string_view str, char delimiter, bool skip_empty = true); /// Joins a string together using the specified delimiter. template @@ -238,7 +238,7 @@ namespace StringUtil return ret; } template - static inline std::string JoinString(const T& start, const T& end, const std::string_view& delimiter) + static inline std::string JoinString(const T& start, const T& end, const std::string_view delimiter) { std::string ret; for (auto it = start; it != end; ++it) @@ -251,11 +251,11 @@ namespace StringUtil } /// Replaces all instances of search in subject with replacement. - std::string ReplaceAll(const std::string_view& subject, const std::string_view& search, const std::string_view& replacement); - void ReplaceAll(std::string* subject, const std::string_view& search, const std::string_view& replacement); + std::string ReplaceAll(const std::string_view subject, const std::string_view search, const std::string_view replacement); + void ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement); /// Parses an assignment string (Key = Value) into its two components. - bool ParseAssignmentString(const std::string_view& str, std::string_view* key, std::string_view* value); + bool ParseAssignmentString(const std::string_view str, std::string_view* key, std::string_view* value); /// Appends a UTF-16/UTF-32 codepoint to a UTF-8 string. void AppendUTF16CharacterToUTF8(std::string& s, u16 ch); @@ -266,11 +266,11 @@ namespace StringUtil /// Decodes UTF-8 to a single codepoint, updating the position parameter. /// Returns the number of bytes the codepoint took in the original string. size_t DecodeUTF8(const void* bytes, size_t length, char32_t* ch); - size_t DecodeUTF8(const std::string_view& str, size_t offset, char32_t* ch); + size_t DecodeUTF8(const std::string_view str, size_t offset, char32_t* ch); size_t DecodeUTF8(const std::string& str, size_t offset, char32_t* ch); // Replaces the end of a string with ellipsis if it exceeds the specified length. - std::string Ellipsise(const std::string_view& str, u32 max_length, const char* ellipsis = "..."); + std::string Ellipsise(const std::string_view str, u32 max_length, const char* ellipsis = "..."); void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis = "..."); /// Strided memcpy/memcmp. @@ -313,15 +313,15 @@ namespace StringUtil return 0; } - std::string toLower(const std::string_view& str); - std::string toUpper(const std::string_view& str); - bool compareNoCase(const std::string_view& str1, const std::string_view& str2); + std::string toLower(const std::string_view str); + std::string toUpper(const std::string_view str); + bool compareNoCase(const std::string_view str1, const std::string_view str2); std::vector splitOnNewLine(const std::string& str); #ifdef _WIN32 /// Converts the specified UTF-8 string to a wide string. - std::wstring UTF8StringToWideString(const std::string_view& str); - bool UTF8StringToWideString(std::wstring& dest, const std::string_view& str); + std::wstring UTF8StringToWideString(const std::string_view str); + bool UTF8StringToWideString(std::wstring& dest, const std::string_view str); /// Converts the specified wide string to a UTF-8 string. std::string WideStringToUTF8String(const std::wstring_view& str); @@ -333,7 +333,7 @@ namespace StringUtil std::string& AppendU128ToString(const u128& u, std::string& s); template - static inline bool ContainsSubString(const ContainerType& haystack, const std::string_view& needle) + static inline bool ContainsSubString(const ContainerType& haystack, const std::string_view needle) { using ValueType = typename ContainerType::value_type; if (needle.empty()) diff --git a/pcsx2-gsrunner/Main.cpp b/pcsx2-gsrunner/Main.cpp index 4444e6cde3..8b64ae49e2 100644 --- a/pcsx2-gsrunner/Main.cpp +++ b/pcsx2-gsrunner/Main.cpp @@ -165,40 +165,30 @@ void Host::SetDefaultUISettings(SettingsInterface& si) // nothing } -void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) +void Host::ReportErrorAsync(const std::string_view title, const std::string_view message) { if (!title.empty() && !message.empty()) - { - Console.Error( - "ReportErrorAsync: %.*s: %.*s", static_cast(title.size()), title.data(), static_cast(message.size()), message.data()); - } + ERROR_LOG("ReportErrorAsync: {}: {}", title, message); else if (!message.empty()) - { - Console.Error("ReportErrorAsync: %.*s", static_cast(message.size()), message.data()); - } + ERROR_LOG("ReportErrorAsync: {}", message); } -bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) +bool Host::ConfirmMessage(const std::string_view title, const std::string_view message) { if (!title.empty() && !message.empty()) - { - Console.Error( - "ConfirmMessage: %.*s: %.*s", static_cast(title.size()), title.data(), static_cast(message.size()), message.data()); - } + ERROR_LOG("ConfirmMessage: {}: {}", title, message); else if (!message.empty()) - { - Console.Error("ConfirmMessage: %.*s", static_cast(message.size()), message.data()); - } + ERROR_LOG("ConfirmMessage: {}", message); return true; } -void Host::OpenURL(const std::string_view& url) +void Host::OpenURL(const std::string_view url) { // noop } -bool Host::CopyTextToClipboard(const std::string_view& text) +bool Host::CopyTextToClipboard(const std::string_view text) { return false; } @@ -315,15 +305,15 @@ void Host::OnPerformanceMetricsUpdated() { } -void Host::OnSaveStateLoading(const std::string_view& filename) +void Host::OnSaveStateLoading(const std::string_view filename) { } -void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) +void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful) { } -void Host::OnSaveStateSaved(const std::string_view& filename) +void Host::OnSaveStateSaved(const std::string_view filename) { } @@ -411,7 +401,7 @@ void Host::OpenHostFileSelectorAsync(std::string_view title, bool select_directo callback(std::string()); } -std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) +std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view str) { return std::nullopt; } @@ -732,7 +722,7 @@ void Host::PumpMessagesOnCPUThread() } s32 Host::Internal::GetTranslatedStringImpl( - const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) + const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space) { if (msg.size() > tbuf_space) return -1; diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index 9223d0f6b3..ed0cce5aec 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -69,7 +69,7 @@ namespace QtHost { static void InitializeEarlyConsole(); static void PrintCommandLineVersion(); - static void PrintCommandLineHelp(const std::string_view& progname); + static void PrintCommandLineHelp(const std::string_view progname); static std::shared_ptr& AutoBoot(std::shared_ptr& autoboot); static bool ParseCommandLineOptions(const QStringList& args, std::shared_ptr& autoboot); static bool InitializeConfig(); @@ -1085,17 +1085,17 @@ void Host::OnPerformanceMetricsUpdated() g_emu_thread->updatePerformanceMetrics(false); } -void Host::OnSaveStateLoading(const std::string_view& filename) +void Host::OnSaveStateLoading(const std::string_view filename) { emit g_emu_thread->onSaveStateLoading(QtUtils::StringViewToQString(filename)); } -void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) +void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful) { emit g_emu_thread->onSaveStateLoaded(QtUtils::StringViewToQString(filename), was_successful); } -void Host::OnSaveStateSaved(const std::string_view& filename) +void Host::OnSaveStateSaved(const std::string_view filename) { emit g_emu_thread->onSaveStateSaved(QtUtils::StringViewToQString(filename)); } @@ -1618,36 +1618,31 @@ bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url return true; } -void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) +void Host::ReportErrorAsync(const std::string_view title, const std::string_view message) { if (!title.empty() && !message.empty()) - { - Console.Error( - "ReportErrorAsync: %.*s: %.*s", static_cast(title.size()), title.data(), static_cast(message.size()), message.data()); - } + ERROR_LOG("ReportErrorAsync: {}: {}", title, message); else if (!message.empty()) - { - Console.Error("ReportErrorAsync: %.*s", static_cast(message.size()), message.data()); - } + ERROR_LOG("ReportErrorAsync: {}", message); QMetaObject::invokeMethod(g_main_window, "reportError", Qt::QueuedConnection, Q_ARG(const QString&, title.empty() ? QString() : QString::fromUtf8(title.data(), title.size())), Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()))); } -bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) +bool Host::ConfirmMessage(const std::string_view title, const std::string_view message) { const QString qtitle(QString::fromUtf8(title.data(), title.size())); const QString qmessage(QString::fromUtf8(message.data(), message.size())); return g_emu_thread->confirmMessage(qtitle, qmessage); } -void Host::OpenURL(const std::string_view& url) +void Host::OpenURL(const std::string_view url) { QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); }); } -bool Host::CopyTextToClipboard(const std::string_view& text) +bool Host::CopyTextToClipboard(const std::string_view text) { QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() { QClipboard* clipboard = QGuiApplication::clipboard(); @@ -1801,7 +1796,7 @@ void QtHost::PrintCommandLineVersion() std::fprintf(stderr, "\n"); } -void QtHost::PrintCommandLineHelp(const std::string_view& progname) +void QtHost::PrintCommandLineHelp(const std::string_view progname) { PrintCommandLineVersion(); fmt::print(stderr, "Usage: {} [parameters] [--] [boot filename]\n", progname); diff --git a/pcsx2-qt/QtKeyCodes.cpp b/pcsx2-qt/QtKeyCodes.cpp index e8c0173fdd..6b330b6f19 100644 --- a/pcsx2-qt/QtKeyCodes.cpp +++ b/pcsx2-qt/QtKeyCodes.cpp @@ -460,7 +460,7 @@ static constexpr const KeyCodeName s_qt_key_names[] = { {Qt::Key_Camera, "Camera", nullptr}, {Qt::Key_CameraFocus, "CameraFocus", nullptr}}; -std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) +std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view str) { std::string_view compare_name = str; u32 modifier_bits = 0; diff --git a/pcsx2-qt/QtUtils.cpp b/pcsx2-qt/QtUtils.cpp index ea30d51dda..41a7031f80 100644 --- a/pcsx2-qt/QtUtils.cpp +++ b/pcsx2-qt/QtUtils.cpp @@ -189,7 +189,7 @@ namespace QtUtils return OpenURL(parent, QUrl(url)); } - QString StringViewToQString(const std::string_view& str) + QString StringViewToQString(const std::string_view str) { return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size()); } diff --git a/pcsx2-qt/QtUtils.h b/pcsx2-qt/QtUtils.h index 8a47709e2c..88aa4be6f5 100644 --- a/pcsx2-qt/QtUtils.h +++ b/pcsx2-qt/QtUtils.h @@ -68,7 +68,7 @@ namespace QtUtils void OpenURL(QWidget* parent, const QString& url); /// Converts a std::string_view to a QString safely. - QString StringViewToQString(const std::string_view& str); + QString StringViewToQString(const std::string_view str); /// Sets a widget to italics if the setting value is inherited. void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited); diff --git a/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp b/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp index 0c19628754..48e9bbb93e 100644 --- a/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GameCheatSettingsWidget.cpp @@ -192,7 +192,7 @@ void GameCheatSettingsWidget::reloadList() } } -QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_view& parent) +QTreeWidgetItem* GameCheatSettingsWidget::getTreeWidgetParent(const std::string_view parent) { if (parent.empty()) return nullptr; diff --git a/pcsx2-qt/Settings/GameCheatSettingsWidget.h b/pcsx2-qt/Settings/GameCheatSettingsWidget.h index 898d9ee5de..5ee30989f2 100644 --- a/pcsx2-qt/Settings/GameCheatSettingsWidget.h +++ b/pcsx2-qt/Settings/GameCheatSettingsWidget.h @@ -43,7 +43,7 @@ private Q_SLOTS: void reloadList(); private: - QTreeWidgetItem* getTreeWidgetParent(const std::string_view& parent); + QTreeWidgetItem* getTreeWidgetParent(const std::string_view parent); void populateTreeWidgetItem(QTreeWidgetItem* item, const Patch::PatchInfo& pi, bool enabled); void setCheatEnabled(std::string name, bool enabled, bool save_and_reload_settings); void setStateForAll(bool enabled); diff --git a/pcsx2-qt/Settings/SettingsWindow.cpp b/pcsx2-qt/Settings/SettingsWindow.cpp index 749d3adb15..986bb99480 100644 --- a/pcsx2-qt/Settings/SettingsWindow.cpp +++ b/pcsx2-qt/Settings/SettingsWindow.cpp @@ -644,7 +644,7 @@ void SettingsWindow::saveAndReloadGameSettings() g_emu_thread->reloadGameSettings(); } -void SettingsWindow::openGamePropertiesDialog(const GameList::Entry* game, const std::string_view& title, std::string serial, u32 disc_crc) +void SettingsWindow::openGamePropertiesDialog(const GameList::Entry* game, const std::string_view title, std::string serial, u32 disc_crc) { std::string filename = VMManager::GetGameSettingsPath(serial, disc_crc); diff --git a/pcsx2-qt/Settings/SettingsWindow.h b/pcsx2-qt/Settings/SettingsWindow.h index 84485329b3..a7a050b307 100644 --- a/pcsx2-qt/Settings/SettingsWindow.h +++ b/pcsx2-qt/Settings/SettingsWindow.h @@ -45,7 +45,7 @@ public: u32 disc_crc, QString filename = QString()); ~SettingsWindow(); - static void openGamePropertiesDialog(const GameList::Entry* game, const std::string_view& title, std::string serial, u32 disc_crc); + static void openGamePropertiesDialog(const GameList::Entry* game, const std::string_view title, std::string serial, u32 disc_crc); static void closeGamePropertiesDialogs(); SettingsInterface* getSettingsInterface() const; diff --git a/pcsx2-qt/Translations.cpp b/pcsx2-qt/Translations.cpp index a160ac0677..ee96b9c9c6 100644 --- a/pcsx2-qt/Translations.cpp +++ b/pcsx2-qt/Translations.cpp @@ -56,9 +56,9 @@ namespace QtHost const char16_t* used_glyphs; }; - static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language); + static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view language); static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const std::string& path); - static const GlyphInfo* GetGlyphInfo(const std::string_view& language); + static const GlyphInfo* GetGlyphInfo(const std::string_view language); static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf"; @@ -197,7 +197,7 @@ const char* QtHost::GetDefaultLanguage() } s32 Host::Internal::GetTranslatedStringImpl( - const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) + const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space) { // This is really awful. Thankfully we're caching the results... const std::string temp_context(context); @@ -269,7 +269,7 @@ static constexpr const ImWchar s_central_european_ranges[] = { 0x0100, 0x017F, // Central European diacritics }; -void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language) +void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view language) { const GlyphInfo* gi = GetGlyphInfo(language); @@ -418,7 +418,7 @@ static constexpr const QtHost::GlyphInfo s_glyph_info[] = { }; // clang-format on -const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view& language) +const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view language) { for (const GlyphInfo& it : s_glyph_info) { diff --git a/pcsx2/Achievements.cpp b/pcsx2/Achievements.cpp index a8f6c82c79..38ec6e345e 100644 --- a/pcsx2/Achievements.cpp +++ b/pcsx2/Achievements.cpp @@ -108,7 +108,7 @@ namespace Achievements }; } // namespace - static void ReportError(const std::string_view& sv); + static void ReportError(const std::string_view sv); template static void ReportFmtError(fmt::format_string fmt, T&&... args); template @@ -168,7 +168,7 @@ namespace Achievements static void UpdateRichPresence(std::unique_lock& lock); static std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state); - static std::string GetUserBadgePath(const std::string_view& username); + static std::string GetUserBadgePath(const std::string_view username); static std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry); static void DrawAchievement(const rc_client_achievement_t* cheevo); @@ -242,7 +242,7 @@ void Achievements::EndLoadingScreen(bool was_running_idle) ImGuiFullscreen::CloseBackgroundProgressDialog("achievements_loading"); } -void Achievements::ReportError(const std::string_view& sv) +void Achievements::ReportError(const std::string_view sv) { std::string error = fmt::format("Achievements error: {}", sv); Console.Error(error); @@ -1591,7 +1591,7 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t* return path; } -std::string Achievements::GetUserBadgePath(const std::string_view& username) +std::string Achievements::GetUserBadgePath(const std::string_view username) { // definitely want to sanitize usernames... :) std::string path; diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 41d13581df..486e4d4412 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -378,7 +378,7 @@ s32 cdvdWriteConfig(const u8* config) return 0; } -static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error) +static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error) { // Strip out cdrom: prefix, and any leading slashes. size_t start_pos = (elfpath[5] == '0') ? 7 : 6; @@ -416,7 +416,7 @@ static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std return elfo->OpenIsoFile(std::move(iso_filename), isor, isPSXElf, error); } -bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf, Error* error) +bool cdvdLoadElf(ElfObject* elfo, const std::string_view elfpath, bool isPSXElf, Error* error) { if (R3000A::ioman::is_host(elfpath)) { @@ -439,7 +439,7 @@ bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf } } -bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error) +bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error) { if (!elfpath.starts_with("cdrom:") && !elfpath.starts_with("cdrom0:")) return false; diff --git a/pcsx2/CDVD/CDVD.h b/pcsx2/CDVD/CDVD.h index 6877d35c47..d4f13b4f70 100644 --- a/pcsx2/CDVD/CDVD.h +++ b/pcsx2/CDVD/CDVD.h @@ -180,8 +180,8 @@ extern void cdvdWrite(u8 key, u8 rt); extern void cdvdGetDiscInfo(std::string* out_serial, std::string* out_elf_path, std::string* out_version, u32* out_crc, CDVDDiscType* out_disc_type); extern u32 cdvdGetElfCRC(const std::string& path); -extern bool cdvdLoadElf(ElfObject* elfo, const std::string_view& elfpath, bool isPSXElf, Error* error); -extern bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view& elfpath, bool isPSXElf, Error* error); +extern bool cdvdLoadElf(ElfObject* elfo, const std::string_view elfpath, bool isPSXElf, Error* error); +extern bool cdvdLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error); extern s32 cdvdCtrlTrayOpen(); extern s32 cdvdCtrlTrayClose(); diff --git a/pcsx2/CDVD/IsoReader.cpp b/pcsx2/CDVD/IsoReader.cpp index 2d87471bf7..78b6c1baf5 100644 --- a/pcsx2/CDVD/IsoReader.cpp +++ b/pcsx2/CDVD/IsoReader.cpp @@ -17,7 +17,7 @@ IsoReader::IsoReader() = default; IsoReader::~IsoReader() = default; -std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view& path) +std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view path) { const std::string_view::size_type pos = path.find(';'); return (pos != std::string_view::npos) ? path.substr(0, pos) : path; @@ -71,7 +71,7 @@ bool IsoReader::ReadPVD(Error* error) return false; } -std::optional IsoReader::LocateFile(const std::string_view& path, Error* error) +std::optional IsoReader::LocateFile(const std::string_view path, Error* error) { const ISODirectoryEntry* root_de = reinterpret_cast(m_pvd.root_directory_entry); if (path.empty() || path == "/" || path == "\\") @@ -115,7 +115,7 @@ std::string_view IsoReader::GetDirectoryEntryFileName(const u8* sector, u32 de_s } std::optional IsoReader::LocateFile( - const std::string_view& path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error) + const std::string_view path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error) { if (directory_record_size == 0) { @@ -191,7 +191,7 @@ std::optional IsoReader::LocateFile( return std::nullopt; } -std::vector IsoReader::GetFilesInDirectory(const std::string_view& path, Error* error) +std::vector IsoReader::GetFilesInDirectory(const std::string_view path, Error* error) { std::string base_path(path); u32 directory_record_lsn; @@ -252,7 +252,7 @@ std::vector IsoReader::GetFilesInDirectory(const std::string_view& return files; } -bool IsoReader::FileExists(const std::string_view& path, Error* error) +bool IsoReader::FileExists(const std::string_view path, Error* error) { auto de = LocateFile(path, error); if (!de) @@ -261,7 +261,7 @@ bool IsoReader::FileExists(const std::string_view& path, Error* error) return (de->flags & ISODirectoryEntryFlag_Directory) == 0; } -bool IsoReader::DirectoryExists(const std::string_view& path, Error* error) +bool IsoReader::DirectoryExists(const std::string_view path, Error* error) { auto de = LocateFile(path, error); if (!de) @@ -270,7 +270,7 @@ bool IsoReader::DirectoryExists(const std::string_view& path, Error* error) return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory; } -bool IsoReader::ReadFile(const std::string_view& path, std::vector* data, Error* error) +bool IsoReader::ReadFile(const std::string_view path, std::vector* data, Error* error) { auto de = LocateFile(path, error); if (!de) diff --git a/pcsx2/CDVD/IsoReader.h b/pcsx2/CDVD/IsoReader.h index 9ae7c13e1f..b40aff7b58 100644 --- a/pcsx2/CDVD/IsoReader.h +++ b/pcsx2/CDVD/IsoReader.h @@ -136,7 +136,7 @@ public: IsoReader(); ~IsoReader(); - static std::string_view RemoveVersionIdentifierFromPath(const std::string_view& path); + static std::string_view RemoveVersionIdentifierFromPath(const std::string_view path); const ISOPrimaryVolumeDescriptor& GetPVD() const { return m_pvd; } @@ -144,13 +144,13 @@ public: // ... once I have the energy to make CDVD not depend on a global object. bool Open(Error* error = nullptr); - std::vector GetFilesInDirectory(const std::string_view& path, Error* error = nullptr); + std::vector GetFilesInDirectory(const std::string_view path, Error* error = nullptr); - std::optional LocateFile(const std::string_view& path, Error* error); + std::optional LocateFile(const std::string_view path, Error* error); - bool FileExists(const std::string_view& path, Error* error = nullptr); - bool DirectoryExists(const std::string_view& path, Error* error = nullptr); - bool ReadFile(const std::string_view& path, std::vector* data, Error* error = nullptr); + bool FileExists(const std::string_view path, Error* error = nullptr); + bool DirectoryExists(const std::string_view path, Error* error = nullptr); + bool ReadFile(const std::string_view path, std::vector* data, Error* error = nullptr); bool ReadFile(const ISODirectoryEntry& de, std::vector* data, Error* error = nullptr); private: @@ -159,7 +159,7 @@ private: bool ReadSector(u8* buf, u32 lsn, Error* error); bool ReadPVD(Error* error); - std::optional LocateFile(const std::string_view& path, u8* sector_buffer, + std::optional LocateFile(const std::string_view path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error); ISOPrimaryVolumeDescriptor m_pvd = {}; diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 12c4589730..58d2be94e4 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -949,7 +949,7 @@ struct Pcsx2Config bool operator!=(const SpeedhackOptions& right) const; static const char* GetSpeedHackName(SpeedHack id); - static std::optional ParseSpeedHackName(const std::string_view& name); + static std::optional ParseSpeedHackName(const std::string_view name); }; struct DebugOptions diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index efd1fdc03b..dfab49ec9f 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -52,9 +52,9 @@ enum class GSDisplayAlignment class SmallStringBase; // Returns the ID for the specified function, otherwise -1. -s16 GSLookupGetSkipCountFunctionId(const std::string_view& name); -s16 GSLookupBeforeDrawFunctionId(const std::string_view& name); -s16 GSLookupMoveHandlerFunctionId(const std::string_view& name); +s16 GSLookupGetSkipCountFunctionId(const std::string_view name); +s16 GSLookupBeforeDrawFunctionId(const std::string_view name); +s16 GSLookupMoveHandlerFunctionId(const std::string_view name); bool GSopen(const Pcsx2Config::GSOptions& config, GSRendererType renderer, u8* basemem); bool GSreopen(bool recreate_device, bool recreate_renderer, GSRendererType new_renderer, diff --git a/pcsx2/GS/Renderers/DX11/D3D.cpp b/pcsx2/GS/Renderers/DX11/D3D.cpp index b37d959e02..b472db194c 100644 --- a/pcsx2/GS/Renderers/DX11/D3D.cpp +++ b/pcsx2/GS/Renderers/DX11/D3D.cpp @@ -84,7 +84,7 @@ std::vector D3D::GetAdapterNames(IDXGIFactory5* factory) return adapter_names; } -std::vector D3D::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name) +std::vector D3D::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view adapter_name) { std::vector modes; HRESULT hr; @@ -196,7 +196,7 @@ bool D3D::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const return true; } -wil::com_ptr_nothrow D3D::GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name) +wil::com_ptr_nothrow D3D::GetAdapterByName(IDXGIFactory5* factory, const std::string_view name) { if (name.empty()) return {}; @@ -242,7 +242,7 @@ wil::com_ptr_nothrow D3D::GetFirstAdapter(IDXGIFactory5* factory) return adapter; } -wil::com_ptr_nothrow D3D::GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name) +wil::com_ptr_nothrow D3D::GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view name) { wil::com_ptr_nothrow adapter = GetAdapterByName(factory, name); if (!adapter) @@ -479,7 +479,7 @@ GSRendererType D3D::GetPreferredRenderer() #endif // _M_X86 wil::com_ptr_nothrow D3D::CompileShader(D3D::ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug, - const std::string_view& code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { const char* target; diff --git a/pcsx2/GS/Renderers/DX11/D3D.h b/pcsx2/GS/Renderers/DX11/D3D.h index 27592669ed..aa9db86f62 100644 --- a/pcsx2/GS/Renderers/DX11/D3D.h +++ b/pcsx2/GS/Renderers/DX11/D3D.h @@ -23,20 +23,20 @@ namespace D3D std::vector GetAdapterNames(IDXGIFactory5* factory); // returns a list of fullscreen modes for the specified adapter - std::vector GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name); + std::vector GetFullscreenModes(IDXGIFactory5* factory, const std::string_view adapter_name); // returns the fullscreen mode to use for the specified dimensions bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height, float refresh_rate, DXGI_FORMAT format, DXGI_MODE_DESC* fullscreen_mode, IDXGIOutput** output); // get an adapter based on name - wil::com_ptr_nothrow GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name); + wil::com_ptr_nothrow GetAdapterByName(IDXGIFactory5* factory, const std::string_view name); // returns the first adapter in the system wil::com_ptr_nothrow GetFirstAdapter(IDXGIFactory5* factory); // returns the adapter specified in the configuration, or the default - wil::com_ptr_nothrow GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name); + wil::com_ptr_nothrow GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view name); // returns a utf-8 string of the specified adapter's name std::string GetAdapterName(IDXGIAdapter1* adapter); @@ -68,5 +68,5 @@ namespace D3D }; wil::com_ptr_nothrow CompileShader(ShaderType type, D3D_FEATURE_LEVEL feature_level, bool debug, - const std::string_view& code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); + const std::string_view code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); }; // namespace D3D diff --git a/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.cpp b/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.cpp index eedc792a13..59cc0d29af 100644 --- a/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.cpp +++ b/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.cpp @@ -218,7 +218,7 @@ std::string D3D11ShaderCache::GetCacheBaseFileName(D3D_FEATURE_LEVEL feature_lev } D3D11ShaderCache::CacheIndexKey D3D11ShaderCache::GetCacheKey( - D3D::ShaderType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) + D3D::ShaderType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) { union { @@ -263,7 +263,7 @@ D3D11ShaderCache::CacheIndexKey D3D11ShaderCache::GetCacheKey( } wil::com_ptr_nothrow D3D11ShaderCache::GetShaderBlob(D3D::ShaderType type, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { const auto key = GetCacheKey(type, shader_code, macros, entry_point); @@ -284,7 +284,7 @@ wil::com_ptr_nothrow D3D11ShaderCache::GetShaderBlob(D3D::ShaderType t } wil::com_ptr_nothrow D3D11ShaderCache::GetVertexShader(ID3D11Device* device, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { wil::com_ptr_nothrow blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point); @@ -305,7 +305,7 @@ wil::com_ptr_nothrow D3D11ShaderCache::GetVertexShader(ID3D1 bool D3D11ShaderCache::GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs, ID3D11InputLayout** il, const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { wil::com_ptr_nothrow blob = GetShaderBlob(D3D::ShaderType::Vertex, shader_code, macros, entry_point); @@ -332,7 +332,7 @@ bool D3D11ShaderCache::GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D1 } wil::com_ptr_nothrow D3D11ShaderCache::GetPixelShader(ID3D11Device* device, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { wil::com_ptr_nothrow blob = GetShaderBlob(D3D::ShaderType::Pixel, shader_code, macros, entry_point); @@ -352,7 +352,7 @@ wil::com_ptr_nothrow D3D11ShaderCache::GetPixelShader(ID3D11D } wil::com_ptr_nothrow D3D11ShaderCache::GetComputeShader(ID3D11Device* device, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros /* = nullptr */, const char* entry_point /* = "main" */) { wil::com_ptr_nothrow blob = GetShaderBlob(D3D::ShaderType::Compute, shader_code, macros, entry_point); @@ -372,7 +372,7 @@ wil::com_ptr_nothrow D3D11ShaderCache::GetComputeShader(ID3 } wil::com_ptr_nothrow D3D11ShaderCache::CompileAndAddShaderBlob(const CacheIndexKey& key, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) + const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) { wil::com_ptr_nothrow blob = D3D::CompileShader(key.shader_type, m_feature_level, m_debug, shader_code, macros, entry_point); diff --git a/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.h b/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.h index ab0cc1c6cd..81df8a61dc 100644 --- a/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.h +++ b/pcsx2/GS/Renderers/DX11/D3D11ShaderCache.h @@ -22,21 +22,21 @@ public: bool Open(D3D_FEATURE_LEVEL feature_level, bool debug); void Close(); - wil::com_ptr_nothrow GetShaderBlob(D3D::ShaderType type, const std::string_view& shader_code, + wil::com_ptr_nothrow GetShaderBlob(D3D::ShaderType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); - wil::com_ptr_nothrow GetVertexShader(ID3D11Device* device, const std::string_view& shader_code, + wil::com_ptr_nothrow GetVertexShader(ID3D11Device* device, const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); bool GetVertexShaderAndInputLayout(ID3D11Device* device, ID3D11VertexShader** vs, ID3D11InputLayout** il, - const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, const std::string_view& shader_code, + const D3D11_INPUT_ELEMENT_DESC* layout, size_t layout_size, const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); - wil::com_ptr_nothrow GetPixelShader(ID3D11Device* device, const std::string_view& shader_code, + wil::com_ptr_nothrow GetPixelShader(ID3D11Device* device, const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); wil::com_ptr_nothrow GetComputeShader(ID3D11Device* device, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros = nullptr, + const std::string_view shader_code, const D3D_SHADER_MACRO* macros = nullptr, const char* entry_point = "main"); private: @@ -75,14 +75,14 @@ private: using CacheIndex = std::unordered_map; static std::string GetCacheBaseFileName(D3D_FEATURE_LEVEL feature_level, bool debug); - static CacheIndexKey GetCacheKey(D3D::ShaderType type, const std::string_view& shader_code, + static CacheIndexKey GetCacheKey(D3D::ShaderType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); bool CreateNew(const std::string& index_filename, const std::string& blob_filename); bool ReadExisting(const std::string& index_filename, const std::string& blob_filename); wil::com_ptr_nothrow CompileAndAddShaderBlob(const CacheIndexKey& key, - const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); + const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); std::FILE* m_index_file = nullptr; std::FILE* m_blob_file = nullptr; diff --git a/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp b/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp index d310f9904f..2b7f15c470 100644 --- a/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp +++ b/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp @@ -253,7 +253,7 @@ bool D3D12ShaderCache::ReadExisting(const std::string& index_filename, const std return true; } -std::string D3D12ShaderCache::GetCacheBaseFileName(const std::string_view& type, D3D_FEATURE_LEVEL feature_level, bool debug) +std::string D3D12ShaderCache::GetCacheBaseFileName(const std::string_view type, D3D_FEATURE_LEVEL feature_level, bool debug) { std::string base_filename = "d3d12_"; base_filename += type; @@ -286,7 +286,7 @@ union MD5Hash }; D3D12ShaderCache::CacheIndexKey D3D12ShaderCache::GetShaderCacheKey( - EntryType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) + EntryType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point) { union { diff --git a/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.h b/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.h index dc706aae7d..c27061e7c3 100644 --- a/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.h +++ b/pcsx2/GS/Renderers/DX12/D3D12ShaderCache.h @@ -95,9 +95,9 @@ private: using CacheIndex = std::unordered_map; - static std::string GetCacheBaseFileName(const std::string_view& type, D3D_FEATURE_LEVEL feature_level, bool debug); + static std::string GetCacheBaseFileName(const std::string_view type, D3D_FEATURE_LEVEL feature_level, bool debug); static CacheIndexKey GetShaderCacheKey( - EntryType type, const std::string_view& shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); + EntryType type, const std::string_view shader_code, const D3D_SHADER_MACRO* macros, const char* entry_point); static CacheIndexKey GetPipelineCacheKey(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& gpdesc); static CacheIndexKey GetPipelineCacheKey(const D3D12_COMPUTE_PIPELINE_STATE_DESC& gpdesc); diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index 735437ce6c..ca3448b5d9 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -1505,7 +1505,7 @@ const GSHwHack::Entry GSHwHack::s_move_handler_functions[] #undef CRC_F -s16 GSLookupGetSkipCountFunctionId(const std::string_view& name) +s16 GSLookupGetSkipCountFunctionId(const std::string_view name) { for (u32 i = 0; i < std::size(GSHwHack::s_get_skip_count_functions); i++) { @@ -1516,7 +1516,7 @@ s16 GSLookupGetSkipCountFunctionId(const std::string_view& name) return -1; } -s16 GSLookupBeforeDrawFunctionId(const std::string_view& name) +s16 GSLookupBeforeDrawFunctionId(const std::string_view name) { for (u32 i = 0; i < std::size(GSHwHack::s_before_draw_functions); i++) { @@ -1527,7 +1527,7 @@ s16 GSLookupBeforeDrawFunctionId(const std::string_view& name) return -1; } -s16 GSLookupMoveHandlerFunctionId(const std::string_view& name) +s16 GSLookupMoveHandlerFunctionId(const std::string_view name) { for (u32 i = 0; i < std::size(GSHwHack::s_move_handler_functions); i++) { diff --git a/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp b/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp index 74e791857f..1e0bd4467c 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp @@ -28,7 +28,7 @@ static constexpr LoaderDefinition s_loaders[] = { }; -GSTextureReplacements::ReplacementTextureLoader GSTextureReplacements::GetLoader(const std::string_view& filename) +GSTextureReplacements::ReplacementTextureLoader GSTextureReplacements::GetLoader(const std::string_view filename) { const std::string_view extension(Path::GetExtension(filename)); if (extension.empty()) diff --git a/pcsx2/GS/Renderers/HW/GSTextureReplacements.h b/pcsx2/GS/Renderers/HW/GSTextureReplacements.h index fba1d73b99..89a04671e6 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureReplacements.h +++ b/pcsx2/GS/Renderers/HW/GSTextureReplacements.h @@ -49,7 +49,7 @@ namespace GSTextureReplacements /// Loader will take a filename and interpret the format (e.g. DDS, PNG, etc). using ReplacementTextureLoader = bool (*)(const std::string& filename, GSTextureReplacements::ReplacementTexture* tex, bool only_base_image); - ReplacementTextureLoader GetLoader(const std::string_view& filename); + ReplacementTextureLoader GetLoader(const std::string_view filename); /// Saves an image buffer to a PNG file (for dumping). bool SavePNGImage(const std::string& filename, u32 width, u32 height, const u8* buffer, u32 pitch); diff --git a/pcsx2/GS/Renderers/OpenGL/GLProgram.cpp b/pcsx2/GS/Renderers/OpenGL/GLProgram.cpp index 071db3b1c2..170a8aa7ab 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLProgram.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GLProgram.cpp @@ -491,7 +491,7 @@ void GLProgram::BindUniformBlock(const char* name, u32 index) glUniformBlockBinding(m_program_id, location, index); } -void GLProgram::SetName(const std::string_view& name) +void GLProgram::SetName(const std::string_view name) { if (name.empty()) return; diff --git a/pcsx2/GS/Renderers/OpenGL/GLProgram.h b/pcsx2/GS/Renderers/OpenGL/GLProgram.h index 4ef7fd43f6..3b57009850 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLProgram.h +++ b/pcsx2/GS/Renderers/OpenGL/GLProgram.h @@ -73,7 +73,7 @@ public: void BindUniformBlock(const char* name, u32 index); - void SetName(const std::string_view& name); + void SetName(const std::string_view name); void SetFormattedName(const char* format, ...); GLProgram& operator=(const GLProgram&) = delete; diff --git a/pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp b/pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp index ddf7690a1c..cf69f68f7e 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GLShaderCache.cpp @@ -224,7 +224,7 @@ bool GLShaderCache::Recreate() } GLShaderCache::CacheIndexKey GLShaderCache::GetCacheKey( - const std::string_view& vertex_shader, const std::string_view& fragment_shader) + const std::string_view vertex_shader, const std::string_view fragment_shader) { union ShaderHash { @@ -363,8 +363,8 @@ bool GLShaderCache::WriteToBlobFile(const CacheIndexKey& key, const std::vector< return true; } -std::optional GLShaderCache::CompileProgram(const std::string_view& vertex_shader, - const std::string_view& fragment_shader, const PreLinkCallback& callback, bool set_retrievable) +std::optional GLShaderCache::CompileProgram(const std::string_view vertex_shader, + const std::string_view fragment_shader, const PreLinkCallback& callback, bool set_retrievable) { GLProgram prog; if (!prog.Compile(vertex_shader, fragment_shader)) @@ -383,7 +383,7 @@ std::optional GLShaderCache::CompileProgram(const std::string_view& v } std::optional GLShaderCache::CompileComputeProgram( - const std::string_view& glsl, const PreLinkCallback& callback, bool set_retrievable) + const std::string_view glsl, const PreLinkCallback& callback, bool set_retrievable) { GLProgram prog; if (!prog.CompileCompute(glsl)) @@ -402,7 +402,7 @@ std::optional GLShaderCache::CompileComputeProgram( } std::optional GLShaderCache::CompileAndAddProgram(const CacheIndexKey& key, - const std::string_view& vertex_shader, const std::string_view& fragment_shader, const PreLinkCallback& callback) + const std::string_view vertex_shader, const std::string_view fragment_shader, const PreLinkCallback& callback) { #ifdef PCSX2_DEVBUILD Common::Timer timer; @@ -501,7 +501,7 @@ bool GLShaderCache::GetComputeProgram( } std::optional GLShaderCache::CompileAndAddComputeProgram( - const CacheIndexKey& key, const std::string_view& glsl, const PreLinkCallback& callback) + const CacheIndexKey& key, const std::string_view glsl, const PreLinkCallback& callback) { #ifdef PCSX2_DEVBUILD Common::Timer timer; diff --git a/pcsx2/GS/Renderers/OpenGL/GLShaderCache.h b/pcsx2/GS/Renderers/OpenGL/GLShaderCache.h index 8aa8d98042..a6f88b2cc8 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLShaderCache.h +++ b/pcsx2/GS/Renderers/OpenGL/GLShaderCache.h @@ -67,7 +67,7 @@ private: using CacheIndex = std::unordered_map; - static CacheIndexKey GetCacheKey(const std::string_view& vertex_shader, const std::string_view& fragment_shader); + static CacheIndexKey GetCacheKey(const std::string_view vertex_shader, const std::string_view fragment_shader); std::string GetIndexFileName() const; std::string GetBlobFileName() const; @@ -78,15 +78,15 @@ private: bool WriteToBlobFile(const CacheIndexKey& key, const std::vector& prog_data, u32 prog_format); - std::optional CompileProgram(const std::string_view& vertex_shader, - const std::string_view& fragment_shader, const PreLinkCallback& callback, bool set_retrievable); - std::optional CompileAndAddProgram(const CacheIndexKey& key, const std::string_view& vertex_shader, - const std::string_view& fragment_shader, const PreLinkCallback& callback); + std::optional CompileProgram(const std::string_view vertex_shader, + const std::string_view fragment_shader, const PreLinkCallback& callback, bool set_retrievable); + std::optional CompileAndAddProgram(const CacheIndexKey& key, const std::string_view vertex_shader, + const std::string_view fragment_shader, const PreLinkCallback& callback); std::optional CompileComputeProgram( - const std::string_view& glsl, const PreLinkCallback& callback, bool set_retrievable); + const std::string_view glsl, const PreLinkCallback& callback, bool set_retrievable); std::optional CompileAndAddComputeProgram( - const CacheIndexKey& key, const std::string_view& glsl, const PreLinkCallback& callback); + const CacheIndexKey& key, const std::string_view glsl, const PreLinkCallback& callback); std::FILE* m_index_file = nullptr; std::FILE* m_blob_file = nullptr; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index a4cb000372..4eb43b6098 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -1249,14 +1249,14 @@ GSTexture* GSDeviceOGL::InitPrimDateTexture(GSTexture* rt, const GSVector4i& are return tex; } -std::string GSDeviceOGL::GetShaderSource(const std::string_view& entry, GLenum type, const std::string_view& glsl_h_code, const std::string_view& macro_sel) +std::string GSDeviceOGL::GetShaderSource(const std::string_view entry, GLenum type, const std::string_view glsl_h_code, const std::string_view macro_sel) { std::string src = GenGlslHeader(entry, type, macro_sel); src += glsl_h_code; return src; } -std::string GSDeviceOGL::GenGlslHeader(const std::string_view& entry, GLenum type, const std::string_view& macro) +std::string GSDeviceOGL::GenGlslHeader(const std::string_view entry, GLenum type, const std::string_view macro) { std::string header; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h index a30de2d1cf..0f1d7b1489 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h @@ -353,9 +353,9 @@ public: void SetScissor(const GSVector4i& scissor); bool CreateTextureFX(); - std::string GetShaderSource(const std::string_view& entry, GLenum type, const std::string_view& glsl_h_code, - const std::string_view& macro_sel = std::string_view()); - std::string GenGlslHeader(const std::string_view& entry, GLenum type, const std::string_view& macro); + std::string GetShaderSource(const std::string_view entry, GLenum type, const std::string_view glsl_h_code, + const std::string_view macro_sel = std::string_view()); + std::string GenGlslHeader(const std::string_view entry, GLenum type, const std::string_view macro); std::string GetVSSource(VSSelector sel); std::string GetPSSource(const PSSelector& sel); GLuint CreateSampler(PSSamplerSelector sel); diff --git a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp index 905092ee68..b71e93040a 100644 --- a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp +++ b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.cpp @@ -476,7 +476,7 @@ std::string VKShaderCache::GetPipelineCacheBaseFileName(bool debug) return Path::Combine(EmuFolders::Cache, base_filename); } -VKShaderCache::CacheIndexKey VKShaderCache::GetCacheKey(u32 type, const std::string_view& shader_code) +VKShaderCache::CacheIndexKey VKShaderCache::GetCacheKey(u32 type, const std::string_view shader_code) { union HashParts { diff --git a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.h b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.h index 41f83fa9da..347e06a3bd 100644 --- a/pcsx2/GS/Renderers/Vulkan/VKShaderCache.h +++ b/pcsx2/GS/Renderers/Vulkan/VKShaderCache.h @@ -71,7 +71,7 @@ private: static std::string GetShaderCacheBaseFileName(bool debug); static std::string GetPipelineCacheBaseFileName(bool debug); - static CacheIndexKey GetCacheKey(u32 type, const std::string_view& shader_code); + static CacheIndexKey GetCacheKey(u32 type, const std::string_view shader_code); static std::optional CompileShaderToSPV( u32 stage, std::string_view source, bool debug); diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp index 46af1b52fc..97bab400ce 100644 --- a/pcsx2/GameDatabase.cpp +++ b/pcsx2/GameDatabase.cpp @@ -27,13 +27,13 @@ namespace GameDatabaseSchema { static const char* getHWFixName(GSHWFixId id); - static std::optional parseHWFixName(const std::string_view& name); + static std::optional parseHWFixName(const std::string_view name); static bool isUserHackHWFix(GSHWFixId id); } // namespace GameDatabaseSchema namespace GameDatabase { - static void parseAndInsert(const std::string_view& serial, const c4::yml::NodeRef& node); + static void parseAndInsert(const std::string_view serial, const c4::yml::NodeRef& node); static void initDatabase(); } // namespace GameDatabase @@ -84,7 +84,7 @@ const char* GameDatabaseSchema::GameEntry::compatAsString() const } } -void GameDatabase::parseAndInsert(const std::string_view& serial, const c4::yml::NodeRef& node) +void GameDatabase::parseAndInsert(const std::string_view serial, const c4::yml::NodeRef& node) { GameDatabaseSchema::GameEntry gameEntry; if (node.has_child("name")) @@ -404,7 +404,7 @@ const char* GameDatabaseSchema::getHWFixName(GSHWFixId id) return s_gs_hw_fix_names[static_cast(id)]; } -static std::optional GameDatabaseSchema::parseHWFixName(const std::string_view& name) +static std::optional GameDatabaseSchema::parseHWFixName(const std::string_view name) { for (u32 i = 0; i < std::size(s_gs_hw_fix_names); i++) { @@ -993,7 +993,7 @@ void GameDatabase::ensureLoaded() }); } -const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_view& serial) +const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_view serial) { GameDatabase::ensureLoaded(); @@ -1001,7 +1001,7 @@ const GameDatabaseSchema::GameEntry* GameDatabase::findGame(const std::string_vi return (iter != s_game_db.end()) ? &iter->second : nullptr; } -bool GameDatabase::TrackHash::parseHash(const std::string_view& str) +bool GameDatabase::TrackHash::parseHash(const std::string_view str) { constexpr u32 expected_length = SIZE * 2; if (str.length() != expected_length) diff --git a/pcsx2/GameDatabase.h b/pcsx2/GameDatabase.h index b9f73f213f..1a7dfeb06a 100644 --- a/pcsx2/GameDatabase.h +++ b/pcsx2/GameDatabase.h @@ -125,13 +125,13 @@ namespace GameDatabaseSchema namespace GameDatabase { void ensureLoaded(); - const GameDatabaseSchema::GameEntry* findGame(const std::string_view& serial); + const GameDatabaseSchema::GameEntry* findGame(const std::string_view serial); struct TrackHash { static constexpr u32 SIZE = 16; - bool parseHash(const std::string_view& str); + bool parseHash(const std::string_view str); std::string toString() const; #define MAKE_OPERATOR(op) \ diff --git a/pcsx2/GameList.cpp b/pcsx2/GameList.cpp index 220e34b1da..5043330dab 100644 --- a/pcsx2/GameList.cpp +++ b/pcsx2/GameList.cpp @@ -54,10 +54,10 @@ namespace GameList using CacheMap = UnorderedStringMap; using PlayedTimeMap = UnorderedStringMap; - static bool IsScannableFilename(const std::string_view& path); + static bool IsScannableFilename(const std::string_view path); static bool GetIsoSerialAndCRC(const std::string& path, s32* disc_type, std::string* serial, u32* crc); - static Region ParseDatabaseRegion(const std::string_view& db_region); + static Region ParseDatabaseRegion(const std::string_view db_region); static bool GetElfListEntry(const std::string& path, GameList::Entry* entry); static bool GetIsoListEntry(const std::string& path, GameList::Entry* entry); @@ -129,7 +129,7 @@ const char* GameList::EntryCompatibilityRatingToString(CompatibilityRating ratin // clang-format on } -bool GameList::IsScannableFilename(const std::string_view& path) +bool GameList::IsScannableFilename(const std::string_view path) { return VMManager::IsDiscFileName(path) || VMManager::IsElfFileName(path); } @@ -212,7 +212,7 @@ bool GameList::GetElfListEntry(const std::string& path, GameList::Entry* entry) return true; } -GameList::Region GameList::ParseDatabaseRegion(const std::string_view& db_region) +GameList::Region GameList::ParseDatabaseRegion(const std::string_view db_region) { // clang-format off ////// NTSC ////// @@ -747,7 +747,7 @@ const GameList::Entry* GameList::GetEntryByCRC(u32 crc) return nullptr; } -const GameList::Entry* GameList::GetEntryBySerialAndCRC(const std::string_view& serial, u32 crc) +const GameList::Entry* GameList::GetEntryBySerialAndCRC(const std::string_view serial, u32 crc) { for (const Entry& entry : s_entries) { diff --git a/pcsx2/GameList.h b/pcsx2/GameList.h index 02760753fb..97049d7695 100644 --- a/pcsx2/GameList.h +++ b/pcsx2/GameList.h @@ -121,7 +121,7 @@ namespace GameList const Entry* GetEntryByIndex(u32 index); const Entry* GetEntryForPath(const char* path); const Entry* GetEntryByCRC(u32 crc); - const Entry* GetEntryBySerialAndCRC(const std::string_view& serial, u32 crc); + const Entry* GetEntryBySerialAndCRC(const std::string_view serial, u32 crc); u32 GetEntryCount(); /// Populates the game list with files in the configured directories. diff --git a/pcsx2/Host.cpp b/pcsx2/Host.cpp index 725977c1ae..3a666370bf 100644 --- a/pcsx2/Host.cpp +++ b/pcsx2/Host.cpp @@ -23,7 +23,7 @@ namespace Host { static std::pair LookupTranslationString( - const std::string_view& context, const std::string_view& msg); + const std::string_view context, const std::string_view msg); static std::mutex s_settings_mutex; static LayeredSettingsInterface s_layered_settings_interface; @@ -37,7 +37,7 @@ namespace Host static u32 s_translation_string_cache_pos; } // namespace Host -std::pair Host::LookupTranslationString(const std::string_view& context, const std::string_view& msg) +std::pair Host::LookupTranslationString(const std::string_view context, const std::string_view msg) { // TODO: TranslatableString, compile-time hashing. @@ -114,18 +114,18 @@ add_string: return ret; } -const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg) +const char* Host::TranslateToCString(const std::string_view context, const std::string_view msg) { return LookupTranslationString(context, msg).first; } -std::string_view Host::TranslateToStringView(const std::string_view& context, const std::string_view& msg) +std::string_view Host::TranslateToStringView(const std::string_view context, const std::string_view msg) { const auto mp = LookupTranslationString(context, msg); return std::string_view(mp.first, mp.second); } -std::string Host::TranslateToString(const std::string_view& context, const std::string_view& msg) +std::string Host::TranslateToString(const std::string_view context, const std::string_view msg) { return std::string(TranslateToStringView(context, msg)); } @@ -138,7 +138,7 @@ void Host::ClearTranslationCache() s_translation_string_mutex.unlock(); } -void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...) +void Host::ReportFormattedErrorAsync(const std::string_view title, const char* format, ...) { std::va_list ap; va_start(ap, format); @@ -147,7 +147,7 @@ void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* ReportErrorAsync(title, message); } -bool Host::ConfirmFormattedMessage(const std::string_view& title, const char* format, ...) +bool Host::ConfirmFormattedMessage(const std::string_view title, const char* format, ...) { std::va_list ap; va_start(ap, format); diff --git a/pcsx2/Host.h b/pcsx2/Host.h index 0eb469d54d..20c70fbcf6 100644 --- a/pcsx2/Host.h +++ b/pcsx2/Host.h @@ -29,16 +29,16 @@ namespace Host /// Returns a localized version of the specified string within the specified context. /// The pointer is guaranteed to be valid until the next language change. - const char* TranslateToCString(const std::string_view& context, const std::string_view& msg); + const char* TranslateToCString(const std::string_view context, const std::string_view msg); /// Returns a localized version of the specified string within the specified context. /// The view is guaranteed to be valid until the next language change. /// NOTE: When passing this to fmt, positional arguments should be used in the base string, as /// not all locales follow the same word ordering. - std::string_view TranslateToStringView(const std::string_view& context, const std::string_view& msg); + std::string_view TranslateToStringView(const std::string_view context, const std::string_view msg); /// Returns a localized version of the specified string within the specified context. - std::string TranslateToString(const std::string_view& context, const std::string_view& msg); + std::string TranslateToString(const std::string_view context, const std::string_view msg); /// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n. std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count); @@ -49,23 +49,23 @@ namespace Host /// Adds OSD messages, duration is in seconds. void AddOSDMessage(std::string message, float duration = 2.0f); void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f); - void AddIconOSDMessage(std::string key, const char* icon, const std::string_view& message, float duration = 2.0f); + void AddIconOSDMessage(std::string key, const char* icon, const std::string_view message, float duration = 2.0f); void RemoveKeyedOSDMessage(std::string key); void ClearOSDMessages(); /// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller. - void ReportErrorAsync(const std::string_view& title, const std::string_view& message); - void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...); + void ReportErrorAsync(const std::string_view title, const std::string_view message); + void ReportFormattedErrorAsync(const std::string_view title, const char* format, ...); /// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller. - bool ConfirmMessage(const std::string_view& title, const std::string_view& message); - bool ConfirmFormattedMessage(const std::string_view& title, const char* format, ...); + bool ConfirmMessage(const std::string_view title, const std::string_view message); + bool ConfirmFormattedMessage(const std::string_view title, const char* format, ...); /// Opens a URL, using the default application. - void OpenURL(const std::string_view& url); + void OpenURL(const std::string_view url); /// Copies the provided text to the host's clipboard, if present. - bool CopyTextToClipboard(const std::string_view& text); + bool CopyTextToClipboard(const std::string_view text); /// Requests settings reset. Can be called from any thread, will call back and apply on the CPU thread. bool RequestResetSettings(bool folders, bool core, bool controllers, bool hotkeys, bool ui); @@ -156,7 +156,7 @@ namespace Host void SetInputSettingsLayer(SettingsInterface* sif); /// Implementation to retrieve a translated string. - s32 GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space); + s32 GetTranslatedStringImpl(const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space); } // namespace Internal } // namespace Host diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index a03367aad9..82a9de38de 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -229,8 +229,8 @@ namespace FullscreenUI static void DrawStartGameWindow(); static void DrawExitWindow(); static void DrawPauseMenu(MainWindowType type); - static void ExitFullscreenAndOpenURL(const std::string_view& url); - static void CopyTextToClipboard(std::string title, const std::string_view& text); + static void ExitFullscreenAndOpenURL(const std::string_view url); + static void CopyTextToClipboard(std::string title, const std::string_view text); static void DrawAboutWindow(); static void OpenAboutWindow(); static void GetStandardSelectionFooterText(SmallStringBase& dest, bool back_instead_of_cancel); @@ -299,7 +299,7 @@ namespace FullscreenUI static void SwitchToGameSettings(); static void SwitchToGameSettings(const std::string& path); static void SwitchToGameSettings(const GameList::Entry* entry); - static void SwitchToGameSettings(const std::string_view& serial, u32 crc); + static void SwitchToGameSettings(const std::string_view serial, u32 crc); static void DrawSettingsWindow(); static void DrawSummarySettingsPage(); static void DrawInterfaceSettingsPage(); @@ -389,9 +389,9 @@ namespace FullscreenUI static void DrawClampingModeSetting(SettingsInterface* bsi, const char* title, const char* summary, int vunum); static void PopulateGraphicsAdapterList(); static void PopulateGameListDirectoryCache(SettingsInterface* si); - static void PopulatePatchesAndCheatsList(const std::string_view& serial, u32 crc); - static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section, - const std::string_view& key, const std::string_view& display_name); + static void PopulatePatchesAndCheatsList(const std::string_view serial, u32 crc); + static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view section, + const std::string_view key, const std::string_view display_name); static void DrawInputBindingWindow(); static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, const char* name, const char* display_name, const char* icon_name, bool show_type = true); static void ClearInputBindingVariables(); @@ -1589,8 +1589,8 @@ void FullscreenUI::ClearInputBindingVariables() s_input_binding_value_ranges = {}; } -void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section, - const std::string_view& key, const std::string_view& display_name) +void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view section, + const std::string_view key, const std::string_view display_name) { if (s_input_binding_type != InputBindingInfo::Type::Unknown) { @@ -2708,7 +2708,7 @@ void FullscreenUI::SwitchToSettings() s_settings_page = SettingsPage::Interface; } -void FullscreenUI::SwitchToGameSettings(const std::string_view& serial, u32 crc) +void FullscreenUI::SwitchToGameSettings(const std::string_view serial, u32 crc) { s_game_settings_entry.reset(); s_game_settings_interface = std::make_unique(VMManager::GetGameSettingsPath(serial, crc)); @@ -2761,7 +2761,7 @@ void FullscreenUI::PopulateGameListDirectoryCache(SettingsInterface* si) s_game_list_directories_cache.emplace_back(std::move(dir), true); } -void FullscreenUI::PopulatePatchesAndCheatsList(const std::string_view& serial, u32 crc) +void FullscreenUI::PopulatePatchesAndCheatsList(const std::string_view serial, u32 crc) { constexpr auto sort_patches = [](Patch::PatchInfoList& list) { std::sort(list.begin(), list.end(), [](const Patch::PatchInfo& lhs, const Patch::PatchInfo& rhs) { return lhs.name < rhs.name; }); @@ -6519,7 +6519,7 @@ GSTexture* FullscreenUI::GetCoverForCurrentGame() // Overlays ////////////////////////////////////////////////////////////////////////// -void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url) +void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view url) { Host::RunOnCPUThread([url = std::string(url)]() { if (Host::IsFullscreen()) @@ -6529,7 +6529,7 @@ void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url) }); } -void FullscreenUI::CopyTextToClipboard(std::string title, const std::string_view& text) +void FullscreenUI::CopyTextToClipboard(std::string title, const std::string_view text) { if (Host::CopyTextToClipboard(text)) ShowToast(std::string(), std::move(title)); diff --git a/pcsx2/ImGui/ImGuiFullscreen.h b/pcsx2/ImGui/ImGuiFullscreen.h index 9461481534..dfbeb28d73 100644 --- a/pcsx2/ImGui/ImGuiFullscreen.h +++ b/pcsx2/ImGui/ImGuiFullscreen.h @@ -78,7 +78,7 @@ namespace ImGuiFullscreen static __fi ImVec4 ModAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, a); } static __fi ImVec4 MulAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, v.w * a); } - static __fi std::string_view RemoveHash(const std::string_view& s) + static __fi std::string_view RemoveHash(const std::string_view s) { const std::string_view::size_type pos = s.find('#'); return (pos != std::string_view::npos) ? s.substr(0, pos) : s; diff --git a/pcsx2/ImGui/ImGuiManager.cpp b/pcsx2/ImGui/ImGuiManager.cpp index c4fb41b1a7..694a5b937a 100644 --- a/pcsx2/ImGui/ImGuiManager.cpp +++ b/pcsx2/ImGui/ImGuiManager.cpp @@ -631,7 +631,7 @@ void Host::AddKeyedOSDMessage(std::string key, std::string message, float durati s_osd_posted_messages.push_back(std::move(msg)); } -void Host::AddIconOSDMessage(std::string key, const char* icon, const std::string_view& message, float duration /* = 2.0f */) +void Host::AddIconOSDMessage(std::string key, const char* icon, const std::string_view message, float duration /* = 2.0f */) { if (!key.empty()) Console.WriteLn(Color_StrongGreen, fmt::format("OSD [{}]: {}", key, message)); diff --git a/pcsx2/Input/DInputSource.cpp b/pcsx2/Input/DInputSource.cpp index 4d680b0f3b..0a9386c846 100644 --- a/pcsx2/Input/DInputSource.cpp +++ b/pcsx2/Input/DInputSource.cpp @@ -290,7 +290,7 @@ std::vector DInputSource::EnumerateMotors() return {}; } -bool DInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) +bool DInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) { return {}; } @@ -305,7 +305,7 @@ void DInputSource::UpdateMotorState(InputBindingKey large_key, InputBindingKey s // not supported } -std::optional DInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) +std::optional DInputSource::ParseKeyString(const std::string_view device, const std::string_view binding) { if (!device.starts_with("DInput-") || binding.empty()) return std::nullopt; diff --git a/pcsx2/Input/DInputSource.h b/pcsx2/Input/DInputSource.h index 7700c0a1f3..35824db173 100644 --- a/pcsx2/Input/DInputSource.h +++ b/pcsx2/Input/DInputSource.h @@ -42,11 +42,11 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override; void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; - std::optional ParseKeyString(const std::string_view& device, const std::string_view& binding) override; + std::optional ParseKeyString(const std::string_view device, const std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override; diff --git a/pcsx2/Input/InputManager.cpp b/pcsx2/Input/InputManager.cpp index ef1b853f5e..f7f49530c0 100644 --- a/pcsx2/Input/InputManager.cpp +++ b/pcsx2/Input/InputManager.cpp @@ -89,15 +89,15 @@ struct PadVibrationBinding // ------------------------------------------------------------------------ namespace InputManager { - static std::optional ParseHostKeyboardKey(const std::string_view& source, const std::string_view& sub_binding); - static std::optional ParsePointerKey(const std::string_view& source, const std::string_view& sub_binding); + static std::optional ParseHostKeyboardKey(const std::string_view source, const std::string_view sub_binding); + static std::optional ParsePointerKey(const std::string_view source, const std::string_view sub_binding); - static std::vector SplitChord(const std::string_view& binding); - static bool SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding); + static std::vector SplitChord(const std::string_view binding); + static bool SplitBinding(const std::string_view binding, std::string_view* source, std::string_view* sub_binding); static void PrettifyInputBindingPart(const std::string_view binding, SmallString& ret, bool& changed); - static void AddBinding(const std::string_view& binding, const InputEventHandler& handler); + static void AddBinding(const std::string_view binding, const InputEventHandler& handler); static void AddBindings(const std::vector& bindings, const InputEventHandler& handler); - static bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source); + static bool ParseBindingAndGetSource(const std::string_view binding, InputBindingKey* key, InputSource** source); static bool IsAxisHandler(const InputEventHandler& handler); static float ApplySingleBindingScale(float sensitivity, float deadzone, float value); @@ -170,7 +170,7 @@ static std::vector> s_pointer_move_callbacks // Binding Parsing // ------------------------------------------------------------------------ -std::vector InputManager::SplitChord(const std::string_view& binding) +std::vector InputManager::SplitChord(const std::string_view binding) { std::vector parts; @@ -200,7 +200,7 @@ std::vector InputManager::SplitChord(const std::string_view& b return parts; } -bool InputManager::SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding) +bool InputManager::SplitBinding(const std::string_view binding, std::string_view* source, std::string_view* sub_binding) { const std::string_view::size_type slash_pos = binding.find('/'); if (slash_pos == std::string_view::npos) @@ -214,7 +214,7 @@ bool InputManager::SplitBinding(const std::string_view& binding, std::string_vie return true; } -std::optional InputManager::ParseInputBindingKey(const std::string_view& binding) +std::optional InputManager::ParseInputBindingKey(const std::string_view binding) { std::string_view source, sub_binding; if (!SplitBinding(binding, &source, &sub_binding)) @@ -245,7 +245,7 @@ std::optional InputManager::ParseInputBindingKey(const std::str return std::nullopt; } -bool InputManager::ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source) +bool InputManager::ParseBindingAndGetSource(const std::string_view binding, InputBindingKey* key, InputSource** source) { std::string_view source_string, sub_binding; if (!SplitBinding(binding, &source_string, &sub_binding)) @@ -460,7 +460,7 @@ void InputManager::PrettifyInputBindingPart(const std::string_view binding, Smal } -void InputManager::AddBinding(const std::string_view& binding, const InputEventHandler& handler) +void InputManager::AddBinding(const std::string_view binding, const InputEventHandler& handler) { std::shared_ptr ibinding; const std::vector chord_bindings(SplitChord(binding)); @@ -585,7 +585,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type) } } -std::optional InputManager::ParseInputSourceString(const std::string_view& str) +std::optional InputManager::ParseInputSourceString(const std::string_view str) { for (u32 i = 0; i < static_cast(InputSourceType::Count); i++) { @@ -596,7 +596,7 @@ std::optional InputManager::ParseInputSourceString(const std::s return std::nullopt; } -std::optional InputManager::ParseHostKeyboardKey(const std::string_view& source, const std::string_view& sub_binding) +std::optional InputManager::ParseHostKeyboardKey(const std::string_view source, const std::string_view sub_binding) { if (source != "Keyboard") return std::nullopt; @@ -611,7 +611,7 @@ std::optional InputManager::ParseHostKeyboardKey(const std::str return key; } -std::optional InputManager::ParsePointerKey(const std::string_view& source, const std::string_view& sub_binding) +std::optional InputManager::ParsePointerKey(const std::string_view source, const std::string_view sub_binding) { const std::optional pointer_index = StringUtil::FromChars(source.substr(8)); if (!pointer_index.has_value() || pointer_index.value() < 0) @@ -664,7 +664,7 @@ std::optional InputManager::ParsePointerKey(const std::string_v return std::nullopt; } -std::optional InputManager::GetIndexFromPointerBinding(const std::string_view& source) +std::optional InputManager::GetIndexFromPointerBinding(const std::string_view source) { if (!source.starts_with("Pointer-")) return std::nullopt; @@ -1548,7 +1548,7 @@ static void GetKeyboardGenericBindingMapping(std::vectoremplace_back(GenericInputBinding::R3, "Keyboard/4"); } -static bool GetInternalGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) +static bool GetInternalGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) { if (device == "Keyboard") { @@ -1559,7 +1559,7 @@ static bool GetInternalGenericBindingMapping(const std::string_view& device, Inp return false; } -InputManager::GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view& device) +InputManager::GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view device) { GenericInputBindingMapping mapping; diff --git a/pcsx2/Input/InputManager.h b/pcsx2/Input/InputManager.h index c3ffb06b79..ce7ace8d41 100644 --- a/pcsx2/Input/InputManager.h +++ b/pcsx2/Input/InputManager.h @@ -172,16 +172,16 @@ namespace InputManager bool GetInputSourceDefaultEnabled(InputSourceType type); /// Parses an input class string. - std::optional ParseInputSourceString(const std::string_view& str); + std::optional ParseInputSourceString(const std::string_view str); /// Parses a pointer device string, i.e. tells you which pointer is specified. - std::optional GetIndexFromPointerBinding(const std::string_view& str); + std::optional GetIndexFromPointerBinding(const std::string_view str); /// Returns the device name for a pointer index (e.g. Pointer-0). std::string GetPointerDeviceName(u32 pointer_index); /// Converts a key code from a human-readable string to an identifier. - std::optional ConvertHostKeyboardStringToCode(const std::string_view& str); + std::optional ConvertHostKeyboardStringToCode(const std::string_view str); /// Converts a key code from an identifier to a human-readable string. std::optional ConvertHostKeyboardCodeToString(u32 code); @@ -200,7 +200,7 @@ namespace InputManager InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis); /// Parses an input binding key string. - std::optional ParseInputBindingKey(const std::string_view& binding); + std::optional ParseInputBindingKey(const std::string_view binding); /// Converts a input key to a string. std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key); @@ -222,7 +222,7 @@ namespace InputManager /// Retrieves bindings that match the generic bindings for the specified device. using GenericInputBindingMapping = std::vector>; - GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device); + GenericInputBindingMapping GetGenericBindingMapping(const std::string_view device); /// Returns whether a given input source is enabled. bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type); diff --git a/pcsx2/Input/InputSource.cpp b/pcsx2/Input/InputSource.cpp index f19db3d928..fc9d7e6ba5 100644 --- a/pcsx2/Input/InputSource.cpp +++ b/pcsx2/Input/InputSource.cpp @@ -60,7 +60,7 @@ InputBindingKey InputSource::MakeGenericControllerMotorKey(InputSourceType clazz } std::optional InputSource::ParseGenericControllerKey( - InputSourceType clazz, const std::string_view& source, const std::string_view& sub_binding) + InputSourceType clazz, const std::string_view source, const std::string_view sub_binding) { // try to find the number, this function doesn't care about whether it's xinput or sdl or whatever std::string_view::size_type pos = 0; diff --git a/pcsx2/Input/InputSource.h b/pcsx2/Input/InputSource.h index 639239d21a..4664515f27 100644 --- a/pcsx2/Input/InputSource.h +++ b/pcsx2/Input/InputSource.h @@ -27,7 +27,7 @@ public: virtual void PollEvents() = 0; - virtual std::optional ParseKeyString(const std::string_view& device, const std::string_view& binding) = 0; + virtual std::optional ParseKeyString(const std::string_view device, const std::string_view binding) = 0; virtual TinyString ConvertKeyToString(InputBindingKey key) = 0; virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0; @@ -39,7 +39,7 @@ public: /// Retrieves bindings that match the generic bindings for the specified device. /// Returns false if it's not one of our devices. - virtual bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) = 0; + virtual bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) = 0; /// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call. virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0; @@ -62,7 +62,7 @@ public: /// Parses a generic controller key string. static std::optional ParseGenericControllerKey( - InputSourceType clazz, const std::string_view& source, const std::string_view& sub_binding); + InputSourceType clazz, const std::string_view source, const std::string_view sub_binding); /// Converts a generic controller key to a string. static std::string ConvertGenericControllerKeyToString(InputBindingKey key); diff --git a/pcsx2/Input/SDLInputSource.cpp b/pcsx2/Input/SDLInputSource.cpp index 95ad2232bf..52aa905cd8 100644 --- a/pcsx2/Input/SDLInputSource.cpp +++ b/pcsx2/Input/SDLInputSource.cpp @@ -236,7 +236,7 @@ u32 SDLInputSource::GetRGBForPlayerId(SettingsInterface& si, u32 player_id) player_id); } -u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view& str, u32 player_id) +u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view str, u32 player_id) { if (player_id >= MAX_LED_COLORS) return 0; @@ -349,7 +349,7 @@ std::vector> SDLInputSource::EnumerateDevice return ret; } -std::optional SDLInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) +std::optional SDLInputSource::ParseKeyString(const std::string_view device, const std::string_view binding) { if (!device.starts_with("SDL-") || binding.empty()) return std::nullopt; @@ -596,7 +596,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event) } } -SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view& device) +SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view device) { if (!device.starts_with("SDL-")) return nullptr; @@ -917,7 +917,7 @@ std::vector SDLInputSource::EnumerateMotors() return ret; } -bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) +bool SDLInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) { if (!device.starts_with("SDL-")) return false; @@ -939,27 +939,27 @@ bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, In const GenericInputBinding negative = s_sdl_generic_binding_axis_mapping[i][0]; const GenericInputBinding positive = s_sdl_generic_binding_axis_mapping[i][1]; if (negative != GenericInputBinding::Unknown) - mapping->emplace_back(negative, StringUtil::StdStringFromFormat("SDL-%d/-%s", pid, s_sdl_axis_names[i])); + mapping->emplace_back(negative, fmt::format("SDL-{}/-{}", pid, s_sdl_axis_names[i])); if (positive != GenericInputBinding::Unknown) - mapping->emplace_back(positive, StringUtil::StdStringFromFormat("SDL-%d/+%s", pid, s_sdl_axis_names[i])); + mapping->emplace_back(positive, fmt::format("SDL-{}/+{}", pid, s_sdl_axis_names[i])); } for (u32 i = 0; i < std::size(s_sdl_generic_binding_button_mapping); i++) { const GenericInputBinding binding = s_sdl_generic_binding_button_mapping[i]; if (binding != GenericInputBinding::Unknown) - mapping->emplace_back(binding, StringUtil::StdStringFromFormat("SDL-%d/%s", pid, s_sdl_button_names[i])); + mapping->emplace_back(binding, fmt::format("SDL-{}/{}", pid, s_sdl_button_names[i])); } if (it->use_game_controller_rumble || it->haptic_left_right_effect) { - mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("SDL-%d/SmallMotor", pid)); - mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("SDL-%d/LargeMotor", pid)); + mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("SDL-{}/SmallMotor", pid)); + mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("SDL-{}/LargeMotor", pid)); } else { - mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("SDL-%d/Haptic", pid)); - mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("SDL-%d/Haptic", pid)); + mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("SDL-{}/Haptic", pid)); + mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("SDL-{}/Haptic", pid)); } return true; diff --git a/pcsx2/Input/SDLInputSource.h b/pcsx2/Input/SDLInputSource.h index 4233d7806f..f123fd0d12 100644 --- a/pcsx2/Input/SDLInputSource.h +++ b/pcsx2/Input/SDLInputSource.h @@ -30,20 +30,20 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override; void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; - std::optional ParseKeyString(const std::string_view& device, const std::string_view& binding) override; + std::optional ParseKeyString(const std::string_view device, const std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override; bool ProcessSDLEvent(const SDL_Event* event); - SDL_Joystick* GetJoystickForDevice(const std::string_view& device); + SDL_Joystick* GetJoystickForDevice(const std::string_view device); static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id); - static u32 ParseRGBForPlayerId(const std::string_view& str, u32 player_id); + static u32 ParseRGBForPlayerId(const std::string_view str, u32 player_id); private: struct ControllerData diff --git a/pcsx2/Input/XInputSource.cpp b/pcsx2/Input/XInputSource.cpp index 923037146e..f1cad71965 100644 --- a/pcsx2/Input/XInputSource.cpp +++ b/pcsx2/Input/XInputSource.cpp @@ -250,7 +250,7 @@ std::vector> XInputSource::EnumerateDevices( return ret; } -std::optional XInputSource::ParseKeyString(const std::string_view& device, const std::string_view& binding) +std::optional XInputSource::ParseKeyString(const std::string_view device, const std::string_view binding) { if (!device.starts_with("XInput-") || binding.empty()) return std::nullopt; @@ -383,7 +383,7 @@ std::vector XInputSource::EnumerateMotors() return ret; } -bool XInputSource::GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) +bool XInputSource::GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) { if (!device.starts_with("XInput-")) return false; @@ -402,22 +402,22 @@ bool XInputSource::GetGenericBindingMapping(const std::string_view& device, Inpu const GenericInputBinding negative = s_xinput_generic_binding_axis_mapping[i][0]; const GenericInputBinding positive = s_xinput_generic_binding_axis_mapping[i][1]; if (negative != GenericInputBinding::Unknown) - mapping->emplace_back(negative, StringUtil::StdStringFromFormat("XInput-%d/-%s", pid, s_axis_names[i])); + mapping->emplace_back(negative, fmt::format("XInput-{}/-{}", pid, s_axis_names[i])); if (positive != GenericInputBinding::Unknown) - mapping->emplace_back(positive, StringUtil::StdStringFromFormat("XInput-%d/+%s", pid, s_axis_names[i])); + mapping->emplace_back(positive, fmt::format("XInput-{}/+{}", pid, s_axis_names[i])); } for (u32 i = 0; i < std::size(s_xinput_generic_binding_button_mapping); i++) { const GenericInputBinding binding = s_xinput_generic_binding_button_mapping[i]; if (binding != GenericInputBinding::Unknown) - mapping->emplace_back(binding, StringUtil::StdStringFromFormat("XInput-%d/%s", pid, s_button_names[i])); + mapping->emplace_back(binding, fmt::format("XInput-{}/{}", pid, s_button_names[i])); } if (m_controllers[pid].has_small_motor) - mapping->emplace_back(GenericInputBinding::SmallMotor, StringUtil::StdStringFromFormat("XInput-%d/SmallMotor", pid)); + mapping->emplace_back(GenericInputBinding::SmallMotor, fmt::format("XInput-{}/SmallMotor", pid)); if (m_controllers[pid].has_large_motor) - mapping->emplace_back(GenericInputBinding::LargeMotor, StringUtil::StdStringFromFormat("XInput-%d/LargeMotor", pid)); + mapping->emplace_back(GenericInputBinding::LargeMotor, fmt::format("XInput-{}/LargeMotor", pid)); return true; } diff --git a/pcsx2/Input/XInputSource.h b/pcsx2/Input/XInputSource.h index 6dea8ce92c..40f95bd13a 100644 --- a/pcsx2/Input/XInputSource.h +++ b/pcsx2/Input/XInputSource.h @@ -79,11 +79,11 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, InputManager::GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(const std::string_view device, InputManager::GenericInputBindingMapping* mapping) override; void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, float small_intensity) override; - std::optional ParseKeyString(const std::string_view& device, const std::string_view& binding) override; + std::optional ParseKeyString(const std::string_view device, const std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override; diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index d53347fded..b416ce8390 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -56,7 +56,7 @@ namespace Patch {"byte", "short", "word", "double", "extended", "beshort", "beword", "bedouble", "bytes"}}; template - static inline std::optional LookupEnumName(const std::string_view& val, const ArrayType& arr) + static inline std::optional LookupEnumName(const std::string_view val, const ArrayType& arr) { for (size_t i = 0; i < arr.size(); i++) { @@ -120,7 +120,7 @@ namespace Patch { int code; const char* text; - void (*func)(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); + void (*func)(PatchGroup* group, const std::string_view cmd, const std::string_view param); }; using PatchList = std::vector; @@ -129,27 +129,27 @@ namespace Patch namespace PatchFunc { - static void patch(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); - static void gsaspectratio(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); - static void gsinterlacemode(PatchGroup* group, const std::string_view& cmd, const std::string_view& param); + static void patch(PatchGroup* group, const std::string_view cmd, const std::string_view param); + static void gsaspectratio(PatchGroup* group, const std::string_view cmd, const std::string_view param); + static void gsinterlacemode(PatchGroup* group, const std::string_view cmd, const std::string_view param); } // namespace PatchFunc static void TrimPatchLine(std::string& buffer); - static int PatchTableExecute(PatchGroup* group, const std::string_view& lhs, const std::string_view& rhs, + static int PatchTableExecute(PatchGroup* group, const std::string_view lhs, const std::string_view rhs, const std::span& Table); - static void LoadPatchLine(PatchGroup* group, const std::string_view& line); + static void LoadPatchLine(PatchGroup* group, const std::string_view line); static u32 LoadPatchesFromString(PatchList* patch_list, const std::string& patch_file); static bool OpenPatchesZip(); static std::string GetPnachTemplate( - const std::string_view& serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs); + const std::string_view serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs); static std::vector FindPatchFilesOnDisk( - const std::string_view& serial, u32 crc, bool cheats, bool all_crcs); + const std::string_view serial, u32 crc, bool cheats, bool all_crcs); static bool ContainsPatchName(const PatchInfoList& patches, const std::string_view patchName); static bool ContainsPatchName(const PatchList& patches, const std::string_view patchName); template - static void EnumeratePnachFiles(const std::string_view& serial, u32 crc, bool cheats, bool for_ui, const F& f); + static void EnumeratePnachFiles(const std::string_view serial, u32 crc, bool cheats, bool for_ui, const F& f); static bool PatchStringHasUnlabelledPatch(const std::string& pnach_data); static void ExtractPatchInfo(PatchInfoList* dst, const std::string& pnach_data, u32* num_unlabelled_patches); @@ -213,7 +213,7 @@ bool Patch::ContainsPatchName(const PatchList& patch_list, const std::string_vie }) != patch_list.end(); } -int Patch::PatchTableExecute(PatchGroup* group, const std::string_view& lhs, const std::string_view& rhs, +int Patch::PatchTableExecute(PatchGroup* group, const std::string_view lhs, const std::string_view rhs, const std::span& Table) { int i = 0; @@ -233,7 +233,7 @@ int Patch::PatchTableExecute(PatchGroup* group, const std::string_view& lhs, con } // This routine is for executing the commands of the ini file. -void Patch::LoadPatchLine(PatchGroup* group, const std::string_view& line) +void Patch::LoadPatchLine(PatchGroup* group, const std::string_view line) { std::string_view key, value; StringUtil::ParseAssignmentString(line, &key, &value); @@ -355,7 +355,7 @@ bool Patch::OpenPatchesZip() return true; } -std::string Patch::GetPnachTemplate(const std::string_view& serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs) +std::string Patch::GetPnachTemplate(const std::string_view serial, u32 crc, bool include_serial, bool add_wildcard, bool all_crcs) { pxAssert(!all_crcs || (include_serial && add_wildcard)); if (all_crcs) @@ -366,7 +366,7 @@ std::string Patch::GetPnachTemplate(const std::string_view& serial, u32 crc, boo return fmt::format("{:08X}{}.pnach", crc, add_wildcard ? "*" : ""); } -std::vector Patch::FindPatchFilesOnDisk(const std::string_view& serial, u32 crc, bool cheats, bool all_crcs) +std::vector Patch::FindPatchFilesOnDisk(const std::string_view serial, u32 crc, bool cheats, bool all_crcs) { FileSystem::FindResultsArray files; FileSystem::FindFiles(cheats ? EmuFolders::Cheats.c_str() : EmuFolders::Patches.c_str(), @@ -398,7 +398,7 @@ bool Patch::ContainsPatchName(const PatchInfoList& patches, const std::string_vi } template -void Patch::EnumeratePnachFiles(const std::string_view& serial, u32 crc, bool cheats, bool for_ui, const F& f) +void Patch::EnumeratePnachFiles(const std::string_view serial, u32 crc, bool cheats, bool for_ui, const F& f) { // Prefer files on disk over the zip. std::vector disk_patch_files; @@ -553,7 +553,7 @@ std::string_view Patch::PatchInfo::GetNameParentPart() const return ret; } -Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches) +Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches) { PatchInfoList ret; @@ -568,7 +568,7 @@ Patch::PatchInfoList Patch::GetPatchInfo(const std::string_view& serial, u32 crc return ret; } -std::string Patch::GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats) +std::string Patch::GetPnachFilename(const std::string_view serial, u32 crc, bool cheats) { return Path::Combine(cheats ? EmuFolders::Cheats : EmuFolders::Patches, GetPnachTemplate(serial, crc, true, false, false)); } @@ -798,7 +798,7 @@ void Patch::UnloadPatches() } // PatchFunc Functions. -void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) +void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view cmd, const std::string_view param) { #define PATCH_ERROR(fstring, ...) \ Console.Error(fmt::format("(Patch) Error Parsing: {}={}: " fstring, cmd, param, __VA_ARGS__)) @@ -874,7 +874,7 @@ void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view& cmd, con #undef PATCH_ERROR } -void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) +void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view cmd, const std::string_view param) { for (u32 i = 0; i < static_cast(AspectRatioType::MaxCount); i++) { @@ -888,7 +888,7 @@ void Patch::PatchFunc::gsaspectratio(PatchGroup* group, const std::string_view& Console.Error(fmt::format("Patch error: {} is an unknown aspect ratio.", param)); } -void Patch::PatchFunc::gsinterlacemode(PatchGroup* group, const std::string_view& cmd, const std::string_view& param) +void Patch::PatchFunc::gsinterlacemode(PatchGroup* group, const std::string_view cmd, const std::string_view param) { const std::optional interlace_mode = StringUtil::FromChars(param); if (!interlace_mode.has_value() || interlace_mode.value() < 0 || diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index e99ff26b70..ae9e421145 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -81,10 +81,10 @@ namespace Patch extern const char* CHEATS_CONFIG_SECTION; extern const char* PATCH_ENABLE_CONFIG_KEY; - extern PatchInfoList GetPatchInfo(const std::string_view& serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches); + extern PatchInfoList GetPatchInfo(const std::string_view serial, u32 crc, bool cheats, bool showAllCRCS, u32* num_unlabelled_patches); /// Returns the path to a new cheat/patch pnach for the specified serial and CRC. - extern std::string GetPnachFilename(const std::string_view& serial, u32 crc, bool cheats); + extern std::string GetPnachFilename(const std::string_view serial, u32 crc, bool cheats); /// Reloads cheats/patches. If verbose is set, the number of patches loaded will be shown in the OSD. extern void ReloadPatches(const std::string& serial, u32 crc, bool reload_files, bool reload_enabled_list, bool verbose, bool verbose_if_changed); diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 86b6ae3a1c..87096cd3ee 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -242,7 +242,7 @@ const char* Pcsx2Config::SpeedhackOptions::GetSpeedHackName(SpeedHack id) return s_speed_hack_names[static_cast(id)]; } -std::optional Pcsx2Config::SpeedhackOptions::ParseSpeedHackName(const std::string_view& name) +std::optional Pcsx2Config::SpeedhackOptions::ParseSpeedHackName(const std::string_view name) { for (u32 i = 0; i < std::size(s_speed_hack_names); i++) { diff --git a/pcsx2/SIO/Memcard/MemoryCardFile.cpp b/pcsx2/SIO/Memcard/MemoryCardFile.cpp index cbd097d2eb..662d7dca3d 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFile.cpp +++ b/pcsx2/SIO/Memcard/MemoryCardFile.cpp @@ -890,7 +890,7 @@ std::vector FileMcd_GetAvailableCards(bool include_in_use_card return mcds; } -std::optional FileMcd_GetCardInfo(const std::string_view& name) +std::optional FileMcd_GetCardInfo(const std::string_view name) { std::optional ret; @@ -923,7 +923,7 @@ std::optional FileMcd_GetCardInfo(const std::string_view& name return ret; } -bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, MemoryCardFileType file_type) +bool FileMcd_CreateNewCard(const std::string_view name, MemoryCardType type, MemoryCardFileType file_type) { const std::string full_path(Path::Combine(EmuFolders::MemoryCards, name)); @@ -1018,7 +1018,7 @@ bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, Me return false; } -bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& new_name) +bool FileMcd_RenameCard(const std::string_view name, const std::string_view new_name) { const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name)); const std::string new_name_path(Path::Combine(EmuFolders::MemoryCards, new_name)); @@ -1043,7 +1043,7 @@ bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& ne return true; } -bool FileMcd_DeleteCard(const std::string_view& name) +bool FileMcd_DeleteCard(const std::string_view name) { const std::string name_path(Path::Combine(EmuFolders::MemoryCards, name)); diff --git a/pcsx2/SIO/Memcard/MemoryCardFile.h b/pcsx2/SIO/Memcard/MemoryCardFile.h index e615d492d1..f70baf2463 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFile.h +++ b/pcsx2/SIO/Memcard/MemoryCardFile.h @@ -9,6 +9,7 @@ #include #include #include +#include #include struct McdSizeInfo @@ -52,9 +53,9 @@ void FileMcd_NextFrame(uint port, uint slot); int FileMcd_ReIndex(uint port, uint slot, const std::string& filter); std::vector FileMcd_GetAvailableCards(bool include_in_use_cards); -std::optional FileMcd_GetCardInfo(const std::string_view& name); +std::optional FileMcd_GetCardInfo(const std::string_view name); bool FileMcd_IsMemoryCardFormatted(const std::string& path); bool FileMcd_IsMemoryCardFormatted(std::FILE* fp); -bool FileMcd_CreateNewCard(const std::string_view& name, MemoryCardType type, MemoryCardFileType file_type); -bool FileMcd_RenameCard(const std::string_view& name, const std::string_view& new_name); -bool FileMcd_DeleteCard(const std::string_view& name); \ No newline at end of file +bool FileMcd_CreateNewCard(const std::string_view name, MemoryCardType type, MemoryCardFileType file_type); +bool FileMcd_RenameCard(const std::string_view name, const std::string_view new_name); +bool FileMcd_DeleteCard(const std::string_view name); \ No newline at end of file diff --git a/pcsx2/SIO/Memcard/MemoryCardFolder.cpp b/pcsx2/SIO/Memcard/MemoryCardFolder.cpp index fff1c5e8ee..d054393bde 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFolder.cpp +++ b/pcsx2/SIO/Memcard/MemoryCardFolder.cpp @@ -428,7 +428,7 @@ MemoryCardFileEntry* FolderMemoryCard::AppendFileEntryToDir(const MemoryCardFile return newFileEntry; } -static bool FilterMatches(const std::string_view& fileName, const std::string_view& filter) +static bool FilterMatches(const std::string_view fileName, const std::string_view filter) { std::string_view::size_type start = 0; std::string_view::size_type len = filter.length(); @@ -452,7 +452,7 @@ static bool FilterMatches(const std::string_view& fileName, const std::string_vi return false; } -bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent /* = nullptr */, const bool enableFiltering /* = false */, const std::string_view& filter /* = "" */) +bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent /* = nullptr */, const bool enableFiltering /* = false */, const std::string_view filter /* = "" */) { if (FileSystem::DirectoryExists(dirPath.c_str())) { @@ -1895,7 +1895,7 @@ std::vector FolderMemoryCard::GetOrderedF return result; } -void FolderMemoryCard::DeleteFromIndex(const std::string& filePath, const std::string_view& entry) const +void FolderMemoryCard::DeleteFromIndex(const std::string& filePath, const std::string_view entry) const { const std::string indexName(Path::Combine(filePath, "_pcsx2_index")); @@ -1988,7 +1988,7 @@ FileAccessHelper::~FileAccessHelper() this->CloseAll(); } -std::FILE* FileAccessHelper::Open(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) +std::FILE* FileAccessHelper::Open(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) { std::string filename(folderName); fileRef->GetPath(&filename); @@ -2020,7 +2020,7 @@ std::FILE* FileAccessHelper::Open(const std::string_view& folderName, MemoryCard return file; } -void FileAccessHelper::WriteMetadata(const std::string_view& folderName, const MemoryCardFileMetadataReference* fileRef) +void FileAccessHelper::WriteMetadata(const std::string_view folderName, const MemoryCardFileMetadataReference* fileRef) { std::string fileName(folderName); const bool cleanedFilename = fileRef->GetPath(&fileName); @@ -2112,7 +2112,7 @@ void FileAccessHelper::WriteIndex(const std::string& baseFolderName, MemoryCardF } } -std::FILE* FileAccessHelper::ReOpen(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) +std::FILE* FileAccessHelper::ReOpen(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata /* = false */) { std::string internalPath; fileRef->GetInternalPath(&internalPath); @@ -2158,7 +2158,7 @@ void FileAccessHelper::CloseFileHandle(std::FILE*& file, const MemoryCardFileEnt } } -void FileAccessHelper::CloseMatching(const std::string_view& path) +void FileAccessHelper::CloseMatching(const std::string_view path) { for (auto it = m_files.begin(); it != m_files.end();) { diff --git a/pcsx2/SIO/Memcard/MemoryCardFolder.h b/pcsx2/SIO/Memcard/MemoryCardFolder.h index 28cd33776c..af9ae58d99 100644 --- a/pcsx2/SIO/Memcard/MemoryCardFolder.h +++ b/pcsx2/SIO/Memcard/MemoryCardFolder.h @@ -191,9 +191,9 @@ public: ~FileAccessHelper(); // Get an already opened file if possible, or open a new one and remember it - std::FILE* ReOpen(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); + std::FILE* ReOpen(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); // Close all open files that start with the given path, so either a file if a filename is given or all files in a directory and its subdirectories when a directory is given - void CloseMatching(const std::string_view& path); + void CloseMatching(const std::string_view path); // Close all open files void CloseAll(); // Flush the written data of all open files to the file system @@ -213,12 +213,12 @@ private: static bool CleanMemcardFilenameEndDotOrSpace(char* name, size_t length); // Open a new file and remember it for later - std::FILE* Open(const std::string_view& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); + std::FILE* Open(const std::string_view folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false); // Close a file and delete its handle // If entry is given, it also attempts to set the created and modified timestamps of the file according to the entry void CloseFileHandle(std::FILE*& file, const MemoryCardFileEntry* entry = nullptr); - void WriteMetadata(const std::string_view& folderName, const MemoryCardFileMetadataReference* fileRef); + void WriteMetadata(const std::string_view folderName, const MemoryCardFileMetadataReference* fileRef); }; // -------------------------------------------------------------------------------------- @@ -438,7 +438,7 @@ protected: // - dirPath: the full path to the directory in the host file system // - parent: pointer to the parent dir's quick-access reference element // - enableFiltering and filter: filter loaded contents, see LoadMemoryCardData() - bool AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent = nullptr, const bool enableFiltering = false, const std::string_view& filter = ""); + bool AddFolder(MemoryCardFileEntry* const dirEntry, const std::string& dirPath, MemoryCardFileMetadataReference* parent = nullptr, const bool enableFiltering = false, const std::string_view filter = ""); // adds a file in the host file sytem to the memory card // - dirEntry: the entry of the directory in the parent directory, or the root "." entry @@ -524,7 +524,7 @@ protected: // for legacy entries without an entry in the index file, order is unspecified and should not be relied on std::vector GetOrderedFiles(const std::string& dirPath) const; - void DeleteFromIndex(const std::string& filePath, const std::string_view& entry) const; + void DeleteFromIndex(const std::string& filePath, const std::string_view entry) const; }; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/SIO/Pad/Pad.cpp b/pcsx2/SIO/Pad/Pad.cpp index 73d3e40fa0..e7d13cd5d2 100644 --- a/pcsx2/SIO/Pad/Pad.cpp +++ b/pcsx2/SIO/Pad/Pad.cpp @@ -67,7 +67,7 @@ const char* Pad::ControllerInfo::GetLocalizedName() const return Host::TranslateToCString("Pad", display_name); } -std::optional Pad::ControllerInfo::GetBindIndex(const std::string_view& name) const +std::optional Pad::ControllerInfo::GetBindIndex(const std::string_view name) const { for (u32 i = 0; i < static_cast(bindings.size()); i++) { @@ -268,7 +268,7 @@ const Pad::ControllerInfo* Pad::GetControllerInfo(Pad::ControllerType type) return nullptr; } -const Pad::ControllerInfo* Pad::GetControllerInfoByName(const std::string_view& name) +const Pad::ControllerInfo* Pad::GetControllerInfoByName(const std::string_view name) { for (const ControllerInfo* info : s_controller_info) { diff --git a/pcsx2/SIO/Pad/Pad.h b/pcsx2/SIO/Pad/Pad.h index 457540304d..c509653212 100644 --- a/pcsx2/SIO/Pad/Pad.h +++ b/pcsx2/SIO/Pad/Pad.h @@ -43,7 +43,7 @@ namespace Pad // Returns general information for the specified controller type. const ControllerInfo* GetControllerInfo(Pad::ControllerType type); - const ControllerInfo* GetControllerInfoByName(const std::string_view& name); + const ControllerInfo* GetControllerInfoByName(const std::string_view name); // Returns controller info based on the type in the config. // Needed because we can't just read EmuConfig when altering input profiles. diff --git a/pcsx2/SIO/Pad/PadTypes.h b/pcsx2/SIO/Pad/PadTypes.h index 0a15006397..d0f6513303 100644 --- a/pcsx2/SIO/Pad/PadTypes.h +++ b/pcsx2/SIO/Pad/PadTypes.h @@ -90,7 +90,7 @@ namespace Pad const char* GetLocalizedName() const; /// Returns the index of the specified binding point, by name. - std::optional GetBindIndex(const std::string_view& name) const; + std::optional GetBindIndex(const std::string_view name) const; }; // Total number of pad ports, across both multitaps. diff --git a/pcsx2/USB/USB.cpp b/pcsx2/USB/USB.cpp index 8b1dbaf24e..d4ceae777c 100644 --- a/pcsx2/USB/USB.cpp +++ b/pcsx2/USB/USB.cpp @@ -531,7 +531,7 @@ s64 usb_get_clock() return s_usb_clocks; } -s32 USB::DeviceTypeNameToIndex(const std::string_view& device) +s32 USB::DeviceTypeNameToIndex(const std::string_view device) { RegisterDevice& rd = RegisterDevice::instance(); return rd.Index(device); @@ -555,13 +555,13 @@ std::vector> USB::GetDeviceTypes() return ret; } -const char* USB::GetDeviceName(const std::string_view& device) +const char* USB::GetDeviceName(const std::string_view device) { const DeviceProxy* dev = RegisterDevice::instance().Device(device); return dev ? dev->Name() : TRANSLATE_NOOP("USB", "Not Connected"); } -const char* USB::GetDeviceSubtypeName(const std::string_view& device, u32 subtype) +const char* USB::GetDeviceSubtypeName(const std::string_view device, u32 subtype) { const DeviceProxy* dev = RegisterDevice::instance().Device(device); if (!dev) @@ -574,19 +574,19 @@ const char* USB::GetDeviceSubtypeName(const std::string_view& device, u32 subtyp return subtypes[subtype]; } -std::span USB::GetDeviceSubtypes(const std::string_view& device) +std::span USB::GetDeviceSubtypes(const std::string_view device) { const DeviceProxy* dev = RegisterDevice::instance().Device(device); return dev ? dev->SubTypes() : std::span(); } -std::span USB::GetDeviceBindings(const std::string_view& device, u32 subtype) +std::span USB::GetDeviceBindings(const std::string_view device, u32 subtype) { const DeviceProxy* dev = RegisterDevice::instance().Device(device); return dev ? dev->Bindings(subtype) : std::span(); } -std::span USB::GetDeviceSettings(const std::string_view& device, u32 subtype) +std::span USB::GetDeviceSettings(const std::string_view device, u32 subtype) { const DeviceProxy* dev = RegisterDevice::instance().Device(device); return dev ? dev->Settings(subtype) : std::span(); @@ -619,7 +619,7 @@ void USB::SetDeviceBindValue(u32 port, u32 bind_index, float value) s_usb_device_proxy[port]->SetBindingValue(s_usb_device[port], bind_index, value); } -void USB::InputDeviceConnected(const std::string_view& identifier) +void USB::InputDeviceConnected(const std::string_view identifier) { for (u32 i = 0; i < NUM_PORTS; i++) { @@ -628,7 +628,7 @@ void USB::InputDeviceConnected(const std::string_view& identifier) } } -void USB::InputDeviceDisconnected(const std::string_view& identifier) +void USB::InputDeviceDisconnected(const std::string_view identifier) { for (u32 i = 0; i < NUM_PORTS; i++) { @@ -647,17 +647,17 @@ void USB::SetConfigDevice(SettingsInterface& si, u32 port, const char* devname) si.SetStringValue(GetConfigSection(port).c_str(), "Type", devname); } -u32 USB::GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view& devname) +u32 USB::GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view devname) { return si.GetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), 0u); } -void USB::SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view& devname, u32 subtype) +void USB::SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view devname, u32 subtype) { si.SetUIntValue(GetConfigSection(port).c_str(), fmt::format("{}_subtype", devname).c_str(), subtype); } -std::string USB::GetConfigSubKey(const std::string_view& device, const std::string_view& bind_name) +std::string USB::GetConfigSubKey(const std::string_view device, const std::string_view bind_name) { return fmt::format("{}_{}", device, bind_name); } diff --git a/pcsx2/USB/USB.h b/pcsx2/USB/USB.h index 1f40700070..6dd402a560 100644 --- a/pcsx2/USB/USB.h +++ b/pcsx2/USB/USB.h @@ -22,34 +22,34 @@ namespace USB NUM_PORTS = 2, }; - s32 DeviceTypeNameToIndex(const std::string_view& device); + s32 DeviceTypeNameToIndex(const std::string_view device); const char* DeviceTypeIndexToName(s32 device); std::vector> GetDeviceTypes(); - const char* GetDeviceName(const std::string_view& device); - const char* GetDeviceSubtypeName(const std::string_view& device, u32 subtype); - std::span GetDeviceSubtypes(const std::string_view& device); - std::span GetDeviceBindings(const std::string_view& device, u32 subtype); - std::span GetDeviceSettings(const std::string_view& device, u32 subtype); + const char* GetDeviceName(const std::string_view device); + const char* GetDeviceSubtypeName(const std::string_view device, u32 subtype); + std::span GetDeviceSubtypes(const std::string_view device); + std::span GetDeviceBindings(const std::string_view device, u32 subtype); + std::span GetDeviceSettings(const std::string_view device, u32 subtype); std::span GetDeviceBindings(u32 port); float GetDeviceBindValue(u32 port, u32 bind_index); void SetDeviceBindValue(u32 port, u32 bind_index, float value); /// Called when a new input device is connected. - void InputDeviceConnected(const std::string_view& identifier); + void InputDeviceConnected(const std::string_view identifier); /// Called when an input device is disconnected. - void InputDeviceDisconnected(const std::string_view& identifier); + void InputDeviceDisconnected(const std::string_view identifier); std::string GetConfigSection(int port); std::string GetConfigDevice(const SettingsInterface& si, u32 port); void SetConfigDevice(SettingsInterface& si, u32 port, const char* devname); - u32 GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view& devname); - void SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view& devname, u32 subtype); + u32 GetConfigSubType(const SettingsInterface& si, u32 port, const std::string_view devname); + void SetConfigSubType(SettingsInterface& si, u32 port, const std::string_view devname, u32 subtype); /// Returns the configuration key for the specified bind and device type. - std::string GetConfigSubKey(const std::string_view& device, const std::string_view& bind_name); + std::string GetConfigSubKey(const std::string_view device, const std::string_view bind_name); /// Performs automatic controller mapping with the provided list of generic mappings. bool MapDevice(SettingsInterface& si, u32 port, const std::vector>& mapping); diff --git a/pcsx2/USB/deviceproxy.cpp b/pcsx2/USB/deviceproxy.cpp index cfb87fc410..0f2de2d764 100644 --- a/pcsx2/USB/deviceproxy.cpp +++ b/pcsx2/USB/deviceproxy.cpp @@ -49,11 +49,11 @@ void DeviceProxy::UpdateSettings(USBDevice* dev, SettingsInterface& si) const { } -void DeviceProxy::InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const +void DeviceProxy::InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const { } -void DeviceProxy::InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const +void DeviceProxy::InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const { } diff --git a/pcsx2/USB/deviceproxy.h b/pcsx2/USB/deviceproxy.h index d50b897197..450bea6fd1 100644 --- a/pcsx2/USB/deviceproxy.h +++ b/pcsx2/USB/deviceproxy.h @@ -61,8 +61,8 @@ public: virtual bool Freeze(USBDevice* dev, StateWrapper& sw) const; virtual void UpdateSettings(USBDevice* dev, SettingsInterface& si) const; - virtual void InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const; - virtual void InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const; + virtual void InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const; + virtual void InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const; }; class RegisterDevice @@ -90,7 +90,7 @@ public: registerDeviceMap[key] = std::unique_ptr(creator); } - DeviceProxy* Device(const std::string_view& name) + DeviceProxy* Device(const std::string_view name) { auto proxy = std::find_if(registerDeviceMap.begin(), registerDeviceMap.end(), @@ -108,7 +108,7 @@ public: return (it != registerDeviceMap.end()) ? it->second.get() : nullptr; } - DeviceType Index(const std::string_view& name) + DeviceType Index(const std::string_view name) { auto proxy = std::find_if(registerDeviceMap.begin(), registerDeviceMap.end(), diff --git a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp index 1aaea94813..ce8740b279 100644 --- a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp +++ b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp @@ -32,7 +32,7 @@ namespace usb_pad } } - std::unique_ptr SDLFFDevice::Create(const std::string_view& device) + std::unique_ptr SDLFFDevice::Create(const std::string_view device) { SDLInputSource* source = static_cast(InputManager::GetInputSourceInterface(InputSourceType::SDL)); if (!source) @@ -57,7 +57,7 @@ namespace usb_pad return ret; } - void SDLFFDevice::CreateEffects(const std::string_view& device) + void SDLFFDevice::CreateEffects(const std::string_view device) { constexpr u32 length = 10000; // 10 seconds since NFS games seem to not issue new commands while rotating. diff --git a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h index c906daf9e3..f3f3c68c6f 100644 --- a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h +++ b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h @@ -13,7 +13,7 @@ namespace usb_pad public: ~SDLFFDevice() override; - static std::unique_ptr Create(const std::string_view& device); + static std::unique_ptr Create(const std::string_view device); void SetConstantForce(int level) override; void SetSpringForce(const parsed_ff_data& ff) override; @@ -25,7 +25,7 @@ namespace usb_pad private: SDLFFDevice(SDL_Haptic* haptic); - void CreateEffects(const std::string_view& device); + void CreateEffects(const std::string_view device); void DestroyEffects(); SDL_Haptic* m_haptic = nullptr; diff --git a/pcsx2/USB/usb-pad/usb-pad.cpp b/pcsx2/USB/usb-pad/usb-pad.cpp index b4ebd6f20e..8a5c8e135d 100644 --- a/pcsx2/USB/usb-pad/usb-pad.cpp +++ b/pcsx2/USB/usb-pad/usb-pad.cpp @@ -875,14 +875,14 @@ namespace usb_pad return GetWheelSettings(static_cast(subtype)); } - void PadDevice::InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const + void PadDevice::InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const { PadState* s = USB_CONTAINER_OF(dev, PadState, dev); if (s->mFFdevName == identifier && s->HasFF()) s->OpenFFDevice(); } - void PadDevice::InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const + void PadDevice::InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const { PadState* s = USB_CONTAINER_OF(dev, PadState, dev); if (s->mFFdevName == identifier) diff --git a/pcsx2/USB/usb-pad/usb-pad.h b/pcsx2/USB/usb-pad/usb-pad.h index 24fcf248c2..0fc2681714 100644 --- a/pcsx2/USB/usb-pad/usb-pad.h +++ b/pcsx2/USB/usb-pad/usb-pad.h @@ -77,8 +77,8 @@ namespace usb_pad void UpdateSettings(USBDevice* dev, SettingsInterface& si) const override; float GetBindingValue(const USBDevice* dev, u32 bind_index) const override; void SetBindingValue(USBDevice* dev, u32 bind_index, float value) const override; - void InputDeviceConnected(USBDevice* dev, const std::string_view& identifier) const override; - void InputDeviceDisconnected(USBDevice* dev, const std::string_view& identifier) const override; + void InputDeviceConnected(USBDevice* dev, const std::string_view identifier) const override; + void InputDeviceDisconnected(USBDevice* dev, const std::string_view identifier) const override; std::span SubTypes() const override; std::span Bindings(u32 subtype) const override; std::span Settings(u32 subtype) const override; diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 88c8550121..295491f009 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -697,7 +697,7 @@ bool VMManager::ReloadGameSettings() return true; } -std::string VMManager::GetGameSettingsPath(const std::string_view& game_serial, u32 game_crc) +std::string VMManager::GetGameSettingsPath(const std::string_view game_serial, u32 game_crc) { std::string sanitized_serial(Path::SanitizeFileName(game_serial)); @@ -728,12 +728,12 @@ std::string VMManager::GetDiscOverrideFromGameSettings(const std::string& elf_pa return iso_path; } -std::string VMManager::GetInputProfilePath(const std::string_view& name) +std::string VMManager::GetInputProfilePath(const std::string_view name) { return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name)); } -std::string VMManager::GetDebuggerSettingsFilePath(const std::string_view& game_serial, u32 game_crc) +std::string VMManager::GetDebuggerSettingsFilePath(const std::string_view game_serial, u32 game_crc) { std::string path; if (!game_serial.empty() && game_crc != 0) @@ -2219,28 +2219,28 @@ bool VMManager::ChangeGSDump(const std::string& path) return true; } -bool VMManager::IsElfFileName(const std::string_view& path) +bool VMManager::IsElfFileName(const std::string_view path) { return StringUtil::EndsWithNoCase(path, ".elf"); } -bool VMManager::IsBlockDumpFileName(const std::string_view& path) +bool VMManager::IsBlockDumpFileName(const std::string_view path) { return StringUtil::EndsWithNoCase(path, ".dump"); } -bool VMManager::IsGSDumpFileName(const std::string_view& path) +bool VMManager::IsGSDumpFileName(const std::string_view path) { return (StringUtil::EndsWithNoCase(path, ".gs") || StringUtil::EndsWithNoCase(path, ".gs.xz") || StringUtil::EndsWithNoCase(path, ".gs.zst")); } -bool VMManager::IsSaveStateFileName(const std::string_view& path) +bool VMManager::IsSaveStateFileName(const std::string_view path) { return StringUtil::EndsWithNoCase(path, ".p2s"); } -bool VMManager::IsDiscFileName(const std::string_view& path) +bool VMManager::IsDiscFileName(const std::string_view path) { static const char* extensions[] = {".iso", ".bin", ".img", ".mdf", ".gz", ".cso", ".zso", ".chd"}; @@ -2253,7 +2253,7 @@ bool VMManager::IsDiscFileName(const std::string_view& path) return false; } -bool VMManager::IsLoadableFileName(const std::string_view& path) +bool VMManager::IsLoadableFileName(const std::string_view path) { return IsDiscFileName(path) || IsElfFileName(path) || IsGSDumpFileName(path) || IsBlockDumpFileName(path); } @@ -2956,7 +2956,7 @@ void VMManager::WarnAboutUnsafeSettings() return; std::string messages; - auto append = [&messages](const char* icon, const std::string_view& msg) { + auto append = [&messages](const char* icon, const std::string_view msg) { messages += icon; messages += ' '; messages += msg; diff --git a/pcsx2/VMManager.h b/pcsx2/VMManager.h index bfe02083d0..eaa3383fce 100644 --- a/pcsx2/VMManager.h +++ b/pcsx2/VMManager.h @@ -170,37 +170,37 @@ namespace VMManager bool ChangeGSDump(const std::string& path); /// Returns true if the specified path is an ELF. - bool IsElfFileName(const std::string_view& path); + bool IsElfFileName(const std::string_view path); /// Returns true if the specified path is a blockdump. - bool IsBlockDumpFileName(const std::string_view& path); + bool IsBlockDumpFileName(const std::string_view path); /// Returns true if the specified path is a GS Dump. - bool IsGSDumpFileName(const std::string_view& path); + bool IsGSDumpFileName(const std::string_view path); /// Returns true if the specified path is a save state. - bool IsSaveStateFileName(const std::string_view& path); + bool IsSaveStateFileName(const std::string_view path); /// Returns true if the specified path is a disc image. - bool IsDiscFileName(const std::string_view& path); + bool IsDiscFileName(const std::string_view path); /// Returns true if the specified path is a disc/elf/etc. - bool IsLoadableFileName(const std::string_view& path); + bool IsLoadableFileName(const std::string_view path); /// Returns the serial to use when computing the game settings path for the current game. std::string GetSerialForGameSettings(); /// Returns the path for the game settings ini file for the specified CRC. - std::string GetGameSettingsPath(const std::string_view& game_serial, u32 game_crc); + std::string GetGameSettingsPath(const std::string_view game_serial, u32 game_crc); /// Returns the ISO override for an ELF via gamesettings. std::string GetDiscOverrideFromGameSettings(const std::string& elf_path); /// Returns the path for the input profile ini file with the specified name (may not exist). - std::string GetInputProfilePath(const std::string_view& name); + std::string GetInputProfilePath(const std::string_view name); /// Returns the path for the debugger settings json file for the specified game serial and CRC. - std::string GetDebuggerSettingsFilePath(const std::string_view& game_serial, u32 game_crc); + std::string GetDebuggerSettingsFilePath(const std::string_view game_serial, u32 game_crc); /// Returns the path for the debugger settings json file for the current game. std::string GetDebuggerSettingsFilePathForCurrentGame(); @@ -307,14 +307,14 @@ namespace Host void OnPerformanceMetricsUpdated(); /// Called when a save state is loading, before the file is processed. - void OnSaveStateLoading(const std::string_view& filename); + void OnSaveStateLoading(const std::string_view filename); /// Called after a save state is successfully loaded. If the save state was invalid, was_successful will be false. - void OnSaveStateLoaded(const std::string_view& filename, bool was_successful); + void OnSaveStateLoaded(const std::string_view filename, bool was_successful); /// Called when a save state is being created/saved. The compression/write to disk is asynchronous, so this callback /// just signifies that the save has started, not necessarily completed. - void OnSaveStateSaved(const std::string_view& filename); + void OnSaveStateSaved(const std::string_view filename); /// Provided by the host; called when the running executable changes. void OnGameChanged(const std::string& title, const std::string& elf_override, const std::string& disc_path, diff --git a/tests/ctest/core/StubHost.cpp b/tests/ctest/core/StubHost.cpp index 3c7200e2f9..5982b75b1e 100644 --- a/tests/ctest/core/StubHost.cpp +++ b/tests/ctest/core/StubHost.cpp @@ -33,20 +33,20 @@ void Host::SetDefaultUISettings(SettingsInterface& si) { } -void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) +void Host::ReportErrorAsync(const std::string_view title, const std::string_view message) { } -bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) +bool Host::ConfirmMessage(const std::string_view title, const std::string_view message) { return true; } -void Host::OpenURL(const std::string_view& url) +void Host::OpenURL(const std::string_view url) { } -bool Host::CopyTextToClipboard(const std::string_view& text) +bool Host::CopyTextToClipboard(const std::string_view text) { return false; } @@ -122,15 +122,15 @@ void Host::OnPerformanceMetricsUpdated() { } -void Host::OnSaveStateLoading(const std::string_view& filename) +void Host::OnSaveStateLoading(const std::string_view filename) { } -void Host::OnSaveStateLoaded(const std::string_view& filename, bool was_successful) +void Host::OnSaveStateLoaded(const std::string_view filename, bool was_successful) { } -void Host::OnSaveStateSaved(const std::string_view& filename) +void Host::OnSaveStateSaved(const std::string_view filename) { } @@ -180,7 +180,7 @@ void Host::PumpMessagesOnCPUThread() } s32 Host::Internal::GetTranslatedStringImpl( - const std::string_view& context, const std::string_view& msg, char* tbuf, size_t tbuf_space) + const std::string_view context, const std::string_view msg, char* tbuf, size_t tbuf_space) { if (msg.size() > tbuf_space) return -1; @@ -243,7 +243,7 @@ void Host::OpenHostFileSelectorAsync(std::string_view title, bool select_directo callback(std::string()); } -std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) +std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view str) { return std::nullopt; }