diff --git a/src/common/byte_stream.cpp b/src/common/byte_stream.cpp index f2f4a36f9..d73b7ee92 100644 --- a/src/common/byte_stream.cpp +++ b/src/common/byte_stream.cpp @@ -976,7 +976,7 @@ bool ByteStream::WriteS64(s64 dest) return Write2(&dest, sizeof(s64)); } -bool ByteStream::WriteSizePrefixedString(const std::string_view& str) +bool ByteStream::WriteSizePrefixedString(std::string_view str) { const u32 size = static_cast(str.size()); return (Write2(&size, sizeof(size)) && (size == 0 || Write2(str.data(), size))); @@ -1315,7 +1315,7 @@ std::string ByteStream::ReadStreamToString(ByteStream* stream, bool seek_to_star return ret; } -bool ByteStream::WriteStreamToString(const std::string_view& sv, ByteStream* stream) +bool ByteStream::WriteStreamToString(std::string_view sv, ByteStream* stream) { if (sv.size() > std::numeric_limits::max()) return false; diff --git a/src/common/byte_stream.h b/src/common/byte_stream.h index df02397cc..05318691c 100644 --- a/src/common/byte_stream.h +++ b/src/common/byte_stream.h @@ -102,7 +102,7 @@ public: bool WriteS16(s16 dest); bool WriteS32(s32 dest); bool WriteS64(s64 dest); - bool WriteSizePrefixedString(const std::string_view& str); + bool WriteSizePrefixedString(std::string_view str); // base byte stream creation functions // opens a local file-based stream. fills in error if passed, and returns false if the file cannot be opened. @@ -139,7 +139,7 @@ public: static u32 CopyBytes(ByteStream* pSourceStream, u32 byteCount, ByteStream* pDestinationStream); static std::string ReadStreamToString(ByteStream* stream, bool seek_to_start = true); - static bool WriteStreamToString(const std::string_view& sv, ByteStream* stream); + static bool WriteStreamToString(std::string_view sv, ByteStream* stream); static std::vector ReadBinaryStream(ByteStream* stream, bool seek_to_start = true); static bool WriteBinaryToStream(ByteStream* stream, const void* data, size_t data_length); diff --git a/src/common/cocoa_tools.h b/src/common/cocoa_tools.h index a3554b0a8..bf930ac4b 100644 --- a/src/common/cocoa_tools.h +++ b/src/common/cocoa_tools.h @@ -13,7 +13,7 @@ class Error; #import namespace CocoaTools { -NSString* StringViewToNSString(const std::string_view& str); +NSString* StringViewToNSString(std::string_view str); /// Converts NSError to a human-readable string. std::string NSErrorToString(NSError* error); diff --git a/src/common/cocoa_tools.mm b/src/common/cocoa_tools.mm index b60687952..bbfe031f4 100644 --- a/src/common/cocoa_tools.mm +++ b/src/common/cocoa_tools.mm @@ -15,7 +15,7 @@ #error ARC should not be enabled. #endif -NSString* CocoaTools::StringViewToNSString(const std::string_view& str) +NSString* CocoaTools::StringViewToNSString(std::string_view str) { if (str.empty()) return nil; diff --git a/src/common/crash_handler.cpp b/src/common/crash_handler.cpp index 380d4055b..772219155 100644 --- a/src/common/crash_handler.cpp +++ b/src/common/crash_handler.cpp @@ -176,7 +176,7 @@ bool CrashHandler::Install() return (s_veh_handle != nullptr); } -void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) +void CrashHandler::SetWriteDirectory(std::string_view dump_directory) { if (!s_veh_handle) return; @@ -384,7 +384,7 @@ bool CrashHandler::Install() return true; } -void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) +void CrashHandler::SetWriteDirectory(std::string_view dump_directory) { } @@ -404,7 +404,7 @@ bool CrashHandler::Install() return false; } -void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) +void CrashHandler::SetWriteDirectory(std::string_view dump_directory) { } diff --git a/src/common/crash_handler.h b/src/common/crash_handler.h index faac1b0b0..ac72beef9 100644 --- a/src/common/crash_handler.h +++ b/src/common/crash_handler.h @@ -6,7 +6,7 @@ namespace CrashHandler { bool Install(); -void SetWriteDirectory(const std::string_view& dump_directory); +void SetWriteDirectory(std::string_view dump_directory); void WriteDumpForCaller(); void Uninstall(); } // namespace CrashHandler diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index 55b0394a7..c7cfd391d 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -135,7 +135,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(std::string_view str, bool strip_slashes /* = true */) { std::string ret; ret.reserve(str.length()); @@ -283,7 +283,7 @@ std::wstring FileSystem::GetWin32Path(std::string_view str) #endif -bool Path::IsAbsolute(const std::string_view& path) +bool Path::IsAbsolute(std::string_view path) { #ifdef _WIN32 return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) && @@ -294,7 +294,7 @@ bool Path::IsAbsolute(const std::string_view& path) #endif } -std::string Path::RealPath(const std::string_view& path) +std::string Path::RealPath(std::string_view path) { // Resolve non-absolute paths first. std::vector components; @@ -472,7 +472,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(std::string_view path) { std::string ret; PathAppendString(ret, path); @@ -492,7 +492,7 @@ void Path::ToNativePath(std::string* path) *path = Path::ToNativePath(*path); } -std::string Path::Canonicalize(const std::string_view& path) +std::string Path::Canonicalize(std::string_view path) { std::vector components = Path::SplitNativePath(path); std::vector new_components; @@ -528,7 +528,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(std::string_view path, 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)); @@ -575,7 +575,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(std::string_view path) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -584,7 +584,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(std::string_view path) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -593,7 +593,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(std::string_view path, std::string_view new_extension) { const std::string_view::size_type pos = path.rfind('.'); if (pos == std::string_view::npos) @@ -604,7 +604,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(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) @@ -624,12 +624,12 @@ static std::string_view::size_type GetLastSeperatorPosition(const std::string_vi return last_separator; } -std::string FileSystem::GetDisplayNameFromPath(const std::string_view& path) +std::string FileSystem::GetDisplayNameFromPath(std::string_view path) { return std::string(Path::GetFileName(path)); } -std::string_view Path::GetDirectory(const std::string_view& path) +std::string_view Path::GetDirectory(std::string_view path) { const std::string::size_type pos = GetLastSeperatorPosition(path, false); if (pos == std::string_view::npos) @@ -638,7 +638,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(std::string_view path) { const std::string_view::size_type pos = GetLastSeperatorPosition(path, true); if (pos == std::string_view::npos) @@ -647,7 +647,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(std::string_view path) { const std::string_view filename(GetFileName(path)); const std::string::size_type pos = filename.rfind('.'); @@ -657,7 +657,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(std::string_view path, std::string_view new_filename) { std::string ret; PathAppendString(ret, path); @@ -684,12 +684,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, 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(std::string_view path, std::string_view new_dir) { std::string ret; if (!new_dir.empty()) @@ -731,12 +731,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, std::string_view new_dir) { *path = AppendDirectory(*path, new_dir); } -std::vector Path::SplitWindowsPath(const std::string_view& path) +std::vector Path::SplitWindowsPath(std::string_view path) { std::vector parts; @@ -774,7 +774,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(std::string_view path) { #ifdef _WIN32 return SplitWindowsPath(path); @@ -841,7 +841,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(std::string_view filename, std::string_view new_filename) { std::string new_string; @@ -852,7 +852,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(std::string_view base, std::string_view next) { std::string ret; ret.reserve(base.length() + next.length() + 1); @@ -1193,7 +1193,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, std::string_view sv) { ManagedCFilePtr fp = OpenManagedCFile(filename, "wb"); if (!fp) diff --git a/src/common/file_system.h b/src/common/file_system.h index 53e8185a0..d51d7b799 100644 --- a/src/common/file_system.h +++ b/src/common/file_system.h @@ -61,7 +61,7 @@ namespace FileSystem { using FindResultsArray = std::vector; /// Returns the display name of a filename. Usually this is the same as the path. -std::string GetDisplayNameFromPath(const std::string_view& path); +std::string GetDisplayNameFromPath(std::string_view path); /// Returns a list of "root directories" (i.e. root/home directories on Linux, drive letters on Windows). std::vector GetRootDirectoryList(); @@ -145,7 +145,7 @@ std::optional> ReadBinaryFile(std::FILE* fp); std::optional ReadFileToString(const char* filename, Error* error = nullptr); 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, 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/src/common/log.cpp b/src/common/log.cpp index 78c37f1c8..f7266cdac 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -276,7 +276,7 @@ void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, co }); #elif !defined(__ANDROID__) FormatLogMessageAndPrint(channelName, functionName, level, message, s_console_output_timestamps, true, true, - [level](const std::string_view& message) { + [level](std::string_view message) { const int outputFd = (level <= LOGLEVEL_WARNING) ? STDERR_FILENO : STDOUT_FILENO; write(outputFd, message.data(), message.length()); }); @@ -413,9 +413,9 @@ void Log::FileOutputLogCallback(void* pUserParam, const char* channelName, const if (!s_file_output_enabled) return; - FormatLogMessageAndPrint( - channelName, functionName, level, message, true, false, true, - [](const std::string_view& message) { std::fwrite(message.data(), 1, message.size(), s_file_handle.get()); }); + FormatLogMessageAndPrint(channelName, functionName, level, message, true, false, true, [](std::string_view message) { + std::fwrite(message.data(), 1, message.size(), s_file_handle.get()); + }); } void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamps /* = true */) diff --git a/src/common/path.h b/src/common/path.h index e0303791b..cd78aeab8 100644 --- a/src/common/path.h +++ b/src/common/path.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once @@ -11,21 +11,21 @@ namespace Path { /// Converts any forward slashes to backslashes on Win32. -std::string ToNativePath(const std::string_view& path); +std::string ToNativePath(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(std::string_view filename, 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(std::string_view base, std::string_view next); /// Removes all .. and . components from a path. -std::string Canonicalize(const std::string_view& path); +std::string Canonicalize(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(std::string_view str, bool strip_slashes = true); void SanitizeFileName(std::string* str, bool strip_slashes = true); /// Mutates the path to remove any MAX_PATH limits (for Windows). @@ -33,47 +33,47 @@ std::string RemoveLengthLimits(std::string_view str); void RemoveLengthLimits(std::string* path); /// 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(std::string_view path); /// Resolves any symbolic links in the specified path. -std::string RealPath(const std::string_view& path); +std::string RealPath(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(std::string_view path, 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(std::string_view path); /// Removes the extension of a filename. -std::string_view StripExtension(const std::string_view& path); +std::string_view StripExtension(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(std::string_view path, 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(std::string_view path); /// Returns the filename component of a filename. -std::string_view GetFileName(const std::string_view& path); +std::string_view GetFileName(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(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(std::string_view path, std::string_view new_filename); +void ChangeFileName(std::string* path, 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(std::string_view path, std::string_view new_dir); +void AppendDirectory(std::string* path, 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(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(std::string_view path); std::string JoinNativePath(const std::vector& components); /// URL encodes the specified string. diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 2d30f7e11..33f2c0d18 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -118,7 +118,7 @@ struct AchievementProgressIndicator }; } // namespace -static void ReportError(const std::string_view& sv); +static void ReportError(std::string_view sv); template static void ReportFmtError(fmt::format_string fmt, T&&... args); template @@ -242,7 +242,7 @@ const rc_client_user_game_summary_t& Achievements::GetGameSummary() return s_game_summary; } -void Achievements::ReportError(const std::string_view& sv) +void Achievements::ReportError(std::string_view sv) { std::string error = fmt::format("Achievements error: {}", sv); Log_ErrorPrint(error.c_str()); @@ -1576,7 +1576,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(std::string_view username) { // definitely want to sanitize usernames... :) std::string path; diff --git a/src/core/achievements_private.h b/src/core/achievements_private.h index 0f5a9d149..60a1b2cd1 100644 --- a/src/core/achievements_private.h +++ b/src/core/achievements_private.h @@ -17,7 +17,7 @@ const std::string& GetGameIconPath(); std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state, bool download_if_missing = true); -std::string GetUserBadgePath(const std::string_view& username); +std::string GetUserBadgePath(std::string_view username); std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry); void OpenLeaderboard(const rc_client_leaderboard_t* lboard); diff --git a/src/core/bus.cpp b/src/core/bus.cpp index c5155e5d3..92051a102 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -369,7 +369,7 @@ void Bus::AddTTYCharacter(char ch) } } -void Bus::AddTTYString(const std::string_view& str) +void Bus::AddTTYString(std::string_view str) { for (char ch : str) AddTTYCharacter(ch); diff --git a/src/core/bus.h b/src/core/bus.h index c14463d8f..64ea4d212 100644 --- a/src/core/bus.h +++ b/src/core/bus.h @@ -209,6 +209,6 @@ std::optional SearchMemory(PhysicalMemoryAddress start_ad // TTY Logging. void AddTTYCharacter(char ch); -void AddTTYString(const std::string_view& str); +void AddTTYString(std::string_view str); } // namespace Bus diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 30ec753ca..3654ee34d 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -296,7 +296,7 @@ static void ResampleXAADPCM(const s16* frames_in, u32 num_frames_in); static TinyString LBAToMSFString(CDImage::LBA lba); static void CreateFileMap(); -static void CreateFileMap(IsoReader& iso, const std::string_view& dir); +static void CreateFileMap(IsoReader& iso, std::string_view dir); static const std::string* LookupFileMap(u32 lba, u32* start_lba, u32* end_lba); static std::unique_ptr s_command_event; @@ -3317,7 +3317,7 @@ void CDROM::CreateFileMap() Log_DevFmt("Found {} files", s_file_map.size()); } -void CDROM::CreateFileMap(IsoReader& iso, const std::string_view& dir) +void CDROM::CreateFileMap(IsoReader& iso, std::string_view dir) { for (auto& [path, entry] : iso.GetEntriesInDirectory(dir)) { diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 5847cb4f5..191eef869 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -157,7 +157,7 @@ std::vector> Controller::GetControllerTypeNa return ret; } -std::optional Controller::GetBindIndex(ControllerType type, const std::string_view& bind_name) +std::optional Controller::GetBindIndex(ControllerType type, std::string_view bind_name) { const ControllerInfo* info = GetControllerInfo(type); if (!info) @@ -172,7 +172,7 @@ std::optional Controller::GetBindIndex(ControllerType type, const std::stri return std::nullopt; } -Controller::VibrationCapabilities Controller::GetControllerVibrationCapabilities(const std::string_view& type) +Controller::VibrationCapabilities Controller::GetControllerVibrationCapabilities(std::string_view type) { const ControllerInfo* info = GetControllerInfo(type); return info ? info->vibration_caps : VibrationCapabilities::NoVibration; diff --git a/src/core/controller.h b/src/core/controller.h index 82e460e9a..7ba686b7a 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -102,10 +102,10 @@ public: static std::vector> GetControllerTypeNames(); /// Gets the integer code for an axis in the specified controller type. - static std::optional GetBindIndex(ControllerType type, const std::string_view& bind_name); + static std::optional GetBindIndex(ControllerType type, std::string_view bind_name); /// Returns the vibration configuration for the specified controller type. - static VibrationCapabilities GetControllerVibrationCapabilities(const std::string_view& type); + static VibrationCapabilities GetControllerVibrationCapabilities(std::string_view type); /// Returns general information for the specified controller type. static const ControllerInfo* GetControllerInfo(ControllerType type); diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 50550512e..aa06cfe28 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -229,8 +229,8 @@ static void DrawLandingWindow(); static void DrawStartGameWindow(); static void DrawExitWindow(); static void DrawPauseMenu(); -static void ExitFullscreenAndOpenURL(const std::string_view& url); -static void CopyTextToClipboard(std::string title, const std::string_view& text); +static void ExitFullscreenAndOpenURL(std::string_view url); +static void CopyTextToClipboard(std::string title, std::string_view text); static void DrawAboutWindow(); static void OpenAboutWindow(); static void FixStateIfPaused(); @@ -293,7 +293,7 @@ static void SwitchToSettings(); static void SwitchToGameSettings(); static void SwitchToGameSettings(const GameList::Entry* entry); static void SwitchToGameSettingsForPath(const std::string& path); -static void SwitchToGameSettingsForSerial(const std::string_view& serial); +static void SwitchToGameSettingsForSerial(std::string_view serial); static void DrawSettingsWindow(); static void DrawSummarySettingsPage(); static void DrawInterfaceSettingsPage(); @@ -391,8 +391,8 @@ static void DrawFolderSetting(SettingsInterface* bsi, const char* title, const c static void PopulateGraphicsAdapterList(); static void PopulateGameListDirectoryCache(SettingsInterface* si); static void PopulatePostProcessingChain(SettingsInterface* si); -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 BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, std::string_view section, + std::string_view key, 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, @@ -1754,9 +1754,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, std::string_view section, + std::string_view key, std::string_view display_name) { if (s_input_binding_type != InputBindingInfo::Type::Unknown) { @@ -2738,7 +2737,7 @@ void FullscreenUI::SwitchToSettings() s_settings_page = SettingsPage::Interface; } -void FullscreenUI::SwitchToGameSettingsForSerial(const std::string_view& serial) +void FullscreenUI::SwitchToGameSettingsForSerial(std::string_view serial) { s_game_settings_entry.reset(); s_game_settings_interface = std::make_unique(System::GetGameSettingsPath(serial)); @@ -6837,7 +6836,7 @@ void FullscreenUI::OpenAboutWindow() s_about_window_open = true; } -void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url) +void FullscreenUI::ExitFullscreenAndOpenURL(std::string_view url) { Host::RunOnCPUThread([url = std::string(url)]() { if (Host::IsFullscreen()) @@ -6847,7 +6846,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, std::string_view text) { if (Host::CopyTextToClipboard(text)) ShowToast(std::string(), std::move(title)); diff --git a/src/core/game_database.cpp b/src/core/game_database.cpp index da23dcb7f..1ca69149e 100644 --- a/src/core/game_database.cpp +++ b/src/core/game_database.cpp @@ -37,8 +37,8 @@ enum : u32 GAME_DATABASE_CACHE_VERSION = 7, }; -static Entry* GetMutableEntry(const std::string_view& serial); -static const Entry* GetEntryForId(const std::string_view& code); +static Entry* GetMutableEntry(std::string_view serial); +static const Entry* GetEntryForId(std::string_view code); static bool LoadFromCache(); static bool SaveToCache(); @@ -110,7 +110,7 @@ ALWAYS_INLINE std::string_view to_stringview(const c4::substr& s) return std::string_view(s.data(), s.size()); } -ALWAYS_INLINE c4::csubstr to_csubstr(const std::string_view& sv) +ALWAYS_INLINE c4::csubstr to_csubstr(std::string_view sv) { return c4::csubstr(sv.data(), sv.length()); } @@ -239,7 +239,7 @@ void GameDatabase::Unload() s_loaded = false; } -const GameDatabase::Entry* GameDatabase::GetEntryForId(const std::string_view& code) +const GameDatabase::Entry* GameDatabase::GetEntryForId(std::string_view code) { if (code.empty()) return nullptr; @@ -307,14 +307,14 @@ const GameDatabase::Entry* GameDatabase::GetEntryForGameDetails(const std::strin return nullptr; } -const GameDatabase::Entry* GameDatabase::GetEntryForSerial(const std::string_view& serial) +const GameDatabase::Entry* GameDatabase::GetEntryForSerial(std::string_view serial) { EnsureLoaded(); return GetMutableEntry(serial); } -GameDatabase::Entry* GameDatabase::GetMutableEntry(const std::string_view& serial) +GameDatabase::Entry* GameDatabase::GetMutableEntry(std::string_view serial) { for (Entry& entry : s_entries) { diff --git a/src/core/game_database.h b/src/core/game_database.h index fd77eccb3..364109104 100644 --- a/src/core/game_database.h +++ b/src/core/game_database.h @@ -96,7 +96,7 @@ void Unload(); const Entry* GetEntryForDisc(CDImage* image); const Entry* GetEntryForGameDetails(const std::string& id, u64 hash); -const Entry* GetEntryForSerial(const std::string_view& serial); +const Entry* GetEntryForSerial(std::string_view serial); std::string GetSerialForDisc(CDImage* image); std::string GetSerialForPath(const char* path); diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index 8b249c7e6..753df11ec 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -117,7 +117,7 @@ bool GameList::IsGameListLoaded() return s_game_list_loaded; } -bool GameList::IsScannableFilename(const std::string_view& path) +bool GameList::IsScannableFilename(std::string_view path) { // we don't scan bin files because they'll duplicate if (StringUtil::EndsWithNoCase(path, ".bin")) @@ -707,7 +707,7 @@ std::string GameList::GetCoverImagePathForEntry(const Entry* entry) return GetCoverImagePath(entry->path, entry->serial, entry->title); } -static std::string GetFullCoverPath(const std::string_view& filename, const std::string_view& extension) +static std::string GetFullCoverPath(std::string_view filename, std::string_view extension) { return fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.{}", EmuFolders::Covers, filename, extension); } diff --git a/src/core/game_list.h b/src/core/game_list.h index e3a95536f..ed651b0fc 100644 --- a/src/core/game_list.h +++ b/src/core/game_list.h @@ -68,7 +68,7 @@ struct Entry const char* GetEntryTypeName(EntryType type); const char* GetEntryTypeDisplayName(EntryType type); -bool IsScannableFilename(const std::string_view& path); +bool IsScannableFilename(std::string_view path); /// Populates a game list entry struct with information from the iso/elf. /// Do *not* call while the system is running, it will mess with CDVD state. diff --git a/src/core/gdb_protocol.cpp b/src/core/gdb_protocol.cpp index b7792f262..f0b66168c 100644 --- a/src/core/gdb_protocol.cpp +++ b/src/core/gdb_protocol.cpp @@ -3,8 +3,8 @@ #include "gdb_protocol.h" #include "bus.h" -#include "cpu_core_private.h" #include "cpu_core.h" +#include "cpu_core_private.h" #include "system.h" #include "common/log.h" @@ -20,15 +20,16 @@ Log_SetChannel(GDBProtocol); -namespace GDBProtocol -{ +namespace GDBProtocol { static u8* GetMemoryPointer(PhysicalMemoryAddress address, u32 length) { auto region = Bus::GetMemoryRegionForAddress(address); - if (region) { + if (region) + { u8* data = GetMemoryRegionPointer(*region); - if (data && (address + length <= GetMemoryRegionEnd(*region))) { + if (data && (address + length <= GetMemoryRegionEnd(*region))) + { return data + (address - GetMemoryRegionStart(*region)); } } @@ -36,34 +37,38 @@ static u8* GetMemoryPointer(PhysicalMemoryAddress address, u32 length) return nullptr; } -static u8 ComputeChecksum(const std::string_view& str) +static u8 ComputeChecksum(std::string_view str) { u8 checksum = 0; - for (char c : str) { + for (char c : str) + { checksum = (checksum + c) % 256; } return checksum; } -static std::optional DeserializePacket(const std::string_view& in) +static std::optional DeserializePacket(std::string_view in) { - if ((in.size() < 4) || (in[0] != '$') || (in[in.size()-3] != '#')) { + if ((in.size() < 4) || (in[0] != '$') || (in[in.size() - 3] != '#')) + { return std::nullopt; } - std::string_view data = in.substr(1, in.size()-4); + std::string_view data = in.substr(1, in.size() - 4); - u8 packetChecksum = StringUtil::FromChars(in.substr(in.size()-2, 2), 16).value_or(0); + u8 packetChecksum = StringUtil::FromChars(in.substr(in.size() - 2, 2), 16).value_or(0); u8 computedChecksum = ComputeChecksum(data); - if (packetChecksum == computedChecksum) { - return { data }; + if (packetChecksum == computedChecksum) + { + return {data}; } - else { + else + { return std::nullopt; } } -static std::string SerializePacket(const std::string_view& in) +static std::string SerializePacket(std::string_view in) { std::stringstream ss; ss << '$' << in << '#' << TinyString::from_format("{:02x}", ComputeChecksum(in)); @@ -71,7 +76,7 @@ static std::string SerializePacket(const std::string_view& in) } /// List of GDB remote protocol registers for MIPS III (excluding FP). -static const std::array REGISTERS { +static const std::array REGISTERS{ &CPU::g_state.regs.r[0], &CPU::g_state.regs.r[1], &CPU::g_state.regs.r[2], @@ -117,53 +122,59 @@ static const std::array REGISTERS { constexpr int NUM_GDB_REGISTERS = 73; /// Get stop reason. -static std::optional Cmd$_questionMark(const std::string_view& data) +static std::optional Cmd$_questionMark(std::string_view data) { - return { "S02" }; + return {"S02"}; } /// Get general registers. -static std::optional Cmd$g(const std::string_view& data) +static std::optional Cmd$g(std::string_view data) { std::stringstream ss; - for (u32* reg : REGISTERS) { + for (u32* reg : REGISTERS) + { // Data is in host order (little endian). ss << StringUtil::EncodeHex(reinterpret_cast(reg), 4); } // Pad with dummy data (FP registers stuff). - for (int i = 0; i < NUM_GDB_REGISTERS - static_cast(REGISTERS.size()); i++) { + for (int i = 0; i < NUM_GDB_REGISTERS - static_cast(REGISTERS.size()); i++) + { ss << "00000000"; } - return { ss.str() }; + return {ss.str()}; } /// Set general registers. -static std::optional Cmd$G(const std::string_view& data) +static std::optional Cmd$G(std::string_view data) { - if (data.size() == NUM_GDB_REGISTERS*8) { + if (data.size() == NUM_GDB_REGISTERS * 8) + { int offset = 0; - for (u32* reg : REGISTERS) { + for (u32* reg : REGISTERS) + { // Data is in host order (little endian). - auto value = StringUtil::DecodeHex({data.data()+offset, 8}); - if (value) { + auto value = StringUtil::DecodeHex({data.data() + offset, 8}); + if (value) + { *reg = *reinterpret_cast(&(*value)[0]); } offset += 8; } } - else { - Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %zu", NUM_GDB_REGISTERS*8, data.size()); + else + { + Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %zu", NUM_GDB_REGISTERS * 8, data.size()); } - return { "" }; + return {""}; } /// Get memory. -static std::optional Cmd$m(const std::string_view& data) +static std::optional Cmd$m(std::string_view data) { std::stringstream ss{std::string{data}}; std::string dataAddress, dataLength; @@ -174,20 +185,22 @@ static std::optional Cmd$m(const std::string_view& data) auto address = StringUtil::FromChars(dataAddress, 16); auto length = StringUtil::FromChars(dataLength, 16); - if (address && length) { + if (address && length) + { PhysicalMemoryAddress phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK; u32 phys_length = *length; u8* ptr_data = GetMemoryPointer(phys_addr, phys_length); - if (ptr_data) { - return { StringUtil::EncodeHex(ptr_data, phys_length) }; + if (ptr_data) + { + return {StringUtil::EncodeHex(ptr_data, phys_length)}; } } - return { "E00" }; + return {"E00"}; } /// Set memory. -static std::optional Cmd$M(const std::string_view& data) +static std::optional Cmd$M(std::string_view data) { std::stringstream ss{std::string{data}}; std::string dataAddress, dataLength, dataPayload; @@ -200,95 +213,101 @@ static std::optional Cmd$M(const std::string_view& data) auto length = StringUtil::FromChars(dataLength, 16); auto payload = StringUtil::DecodeHex(dataPayload); - if (address && length && payload && (payload->size() == *length)) { + if (address && length && payload && (payload->size() == *length)) + { u32 phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK; u32 phys_length = *length; u8* ptr_data = GetMemoryPointer(phys_addr, phys_length); - if (ptr_data) { + if (ptr_data) + { memcpy(ptr_data, payload->data(), phys_length); - return { "OK" }; + return {"OK"}; } } - return { "E00" }; + return {"E00"}; } /// Remove hardware breakpoint. -static std::optional Cmd$z1(const std::string_view& data) +static std::optional Cmd$z1(std::string_view data) { auto address = StringUtil::FromChars(data, 16); - if (address) { + if (address) + { CPU::RemoveBreakpoint(CPU::BreakpointType::Execute, *address); - return { "OK" }; + return {"OK"}; } - else { + else + { return std::nullopt; } } /// Insert hardware breakpoint. -static std::optional Cmd$Z1(const std::string_view& data) +static std::optional Cmd$Z1(std::string_view data) { auto address = StringUtil::FromChars(data, 16); - if (address) { + if (address) + { CPU::AddBreakpoint(CPU::BreakpointType::Execute, *address, false); - return { "OK" }; + return {"OK"}; } - else { + else + { return std::nullopt; } } -static std::optional Cmd$vMustReplyEmpty(const std::string_view& data) +static std::optional Cmd$vMustReplyEmpty(std::string_view data) { - return { "" }; + return {""}; } -static std::optional Cmd$qSupported(const std::string_view& data) +static std::optional Cmd$qSupported(std::string_view data) { - return { "" }; + return {""}; } /// List of all GDB remote protocol packets supported by us. -static const std::map(const std::string_view&)>> COMMANDS -{ - { "?", Cmd$_questionMark }, - { "g", Cmd$g }, - { "G", Cmd$G }, - { "m", Cmd$m }, - { "M", Cmd$M }, - { "z0,", Cmd$z1 }, - { "Z0,", Cmd$Z1 }, - { "z1,", Cmd$z1 }, - { "Z1,", Cmd$Z1 }, - { "vMustReplyEmpty", Cmd$vMustReplyEmpty }, - { "qSupported", Cmd$qSupported }, +static const std::map(std::string_view)>> COMMANDS{ + {"?", Cmd$_questionMark}, + {"g", Cmd$g}, + {"G", Cmd$G}, + {"m", Cmd$m}, + {"M", Cmd$M}, + {"z0,", Cmd$z1}, + {"Z0,", Cmd$Z1}, + {"z1,", Cmd$z1}, + {"Z1,", Cmd$Z1}, + {"vMustReplyEmpty", Cmd$vMustReplyEmpty}, + {"qSupported", Cmd$qSupported}, }; -bool IsPacketInterrupt(const std::string_view& data) +bool IsPacketInterrupt(std::string_view data) { - return (data.size() >= 1) && (data[data.size()-1] == '\003'); + return (data.size() >= 1) && (data[data.size() - 1] == '\003'); } -bool IsPacketContinue(const std::string_view& data) +bool IsPacketContinue(std::string_view data) { - return (data.size() >= 5) && (data.substr(data.size()-5) == "$c#63"); + return (data.size() >= 5) && (data.substr(data.size() - 5) == "$c#63"); } -bool IsPacketComplete(const std::string_view& data) +bool IsPacketComplete(std::string_view data) { - return ((data.size() == 1) && (data[0] == '\003')) || - ((data.size() > 3) && (*(data.end()-3) == '#')); + return ((data.size() == 1) && (data[0] == '\003')) || ((data.size() > 3) && (*(data.end() - 3) == '#')); } -std::string ProcessPacket(const std::string_view& data) +std::string ProcessPacket(std::string_view data) { std::string_view trimmedData = data; // Eat ACKs. - while (!trimmedData.empty() && (trimmedData[0] == '+' || trimmedData[0] == '-')) { - if (trimmedData[0] == '-') { + while (!trimmedData.empty() && (trimmedData[0] == '+' || trimmedData[0] == '-')) + { + if (trimmedData[0] == '-') + { Log_ErrorPrint("Received negative ack"); } trimmedData = trimmedData.substr(1); @@ -296,17 +315,20 @@ std::string ProcessPacket(const std::string_view& data) // Validate packet. auto packet = DeserializePacket(trimmedData); - if (!packet) { + if (!packet) + { Log_ErrorPrintf("Malformed packet '%*s'", static_cast(trimmedData.size()), trimmedData.data()); return "-"; } - std::optional reply = { "" }; + std::optional reply = {""}; // Try to invoke packet command. bool processed = false; - for (const auto& command : COMMANDS) { - if (packet->starts_with(command.first)) { + for (const auto& command : COMMANDS) + { + if (packet->starts_with(command.first)) + { Log_DebugPrintf("Processing command '%s'", command.first); // Invoke command, remove command name from payload. @@ -316,10 +338,11 @@ std::string ProcessPacket(const std::string_view& data) } } - if (!processed) { + if (!processed) + { Log_WarningPrintf("Failed to process packet '%*s'", static_cast(trimmedData.size()), trimmedData.data()); } - return reply ? "+"+SerializePacket(*reply) : "+"; + return reply ? "+" + SerializePacket(*reply) : "+"; } } // namespace GDBProtocol diff --git a/src/core/gdb_protocol.h b/src/core/gdb_protocol.h index 49c41cb8e..d0cc1fc2f 100644 --- a/src/core/gdb_protocol.h +++ b/src/core/gdb_protocol.h @@ -4,13 +4,10 @@ #pragma once #include -namespace GDBProtocol -{ - - bool IsPacketInterrupt(const std::string_view& data); - bool IsPacketContinue(const std::string_view& data); - - bool IsPacketComplete(const std::string_view& data); - std::string ProcessPacket(const std::string_view& data); +namespace GDBProtocol { +bool IsPacketInterrupt(std::string_view data); +bool IsPacketContinue(std::string_view data); +bool IsPacketComplete(std::string_view data); +std::string ProcessPacket(std::string_view data); } // namespace GDBProtocol diff --git a/src/core/host.h b/src/core/host.h index 9f07ae8ab..b009f1a6b 100644 --- a/src/core/host.h +++ b/src/core/host.h @@ -74,7 +74,7 @@ SettingsInterface* GetSettingsInterface(); SettingsInterface* GetSettingsInterfaceForBindings(); /// Debugger feedback. -void ReportDebuggerMessage(const std::string_view& message); +void ReportDebuggerMessage(std::string_view message); void ReportFormattedDebuggerMessage(const char* format, ...); /// Returns a list of supported languages and codes (suffixes for translation files). diff --git a/src/core/memory_card_image.cpp b/src/core/memory_card_image.cpp index 000338456..1ee3f52c7 100644 --- a/src/core/memory_card_image.cpp +++ b/src/core/memory_card_image.cpp @@ -329,8 +329,7 @@ bool MemoryCardImage::ReadFile(const DataArray& data, const FileInfo& fi, std::v return true; } -bool MemoryCardImage::WriteFile(DataArray* data, const std::string_view& filename, const std::vector& buffer, - Error* error) +bool MemoryCardImage::WriteFile(DataArray* data, std::string_view filename, const std::vector& buffer, Error* error) { if (buffer.empty()) { diff --git a/src/core/memory_card_image.h b/src/core/memory_card_image.h index 44315986d..e2ff4f679 100644 --- a/src/core/memory_card_image.h +++ b/src/core/memory_card_image.h @@ -51,7 +51,7 @@ bool IsValid(const DataArray& data); u32 GetFreeBlockCount(const DataArray& data); std::vector EnumerateFiles(const DataArray& data, bool include_deleted); bool ReadFile(const DataArray& data, const FileInfo& fi, std::vector* buffer, Error* error); -bool WriteFile(DataArray* data, const std::string_view& filename, const std::vector& buffer, Error* error); +bool WriteFile(DataArray* data, std::string_view filename, const std::vector& buffer, Error* error); bool DeleteFile(DataArray* data, const FileInfo& fi, bool clear_sectors); bool UndeleteFile(DataArray* data, const FileInfo& fi); bool ImportCard(DataArray* data, const char* filename, Error* error); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 7582c9276..b98013082 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1621,7 +1621,7 @@ std::string Settings::GetSharedMemoryCardPath(u32 slot) const return ret; } -std::string Settings::GetGameMemoryCardPath(const std::string_view& serial, u32 slot) +std::string Settings::GetGameMemoryCardPath(std::string_view serial, u32 slot) { return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1)); } diff --git a/src/core/settings.h b/src/core/settings.h index 0af4011da..336fc5035 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -322,7 +322,7 @@ struct Settings std::string GetSharedMemoryCardPath(u32 slot) const; /// Returns the default path to a memory card for a specific game. - static std::string GetGameMemoryCardPath(const std::string_view& serial, u32 slot); + static std::string GetGameMemoryCardPath(std::string_view serial, u32 slot); static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator); static u32 CPUOverclockFractionToPercent(u32 numerator, u32 denominator); diff --git a/src/core/system.cpp b/src/core/system.cpp index 55bbf95c6..516492d25 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -540,18 +540,18 @@ u32 System::GetFrameTimeHistoryPos() return s_frame_time_history_pos; } -bool System::IsExeFileName(const std::string_view& path) +bool System::IsExeFileName(std::string_view path) { return (StringUtil::EndsWithNoCase(path, ".exe") || StringUtil::EndsWithNoCase(path, ".psexe") || StringUtil::EndsWithNoCase(path, ".ps-exe")); } -bool System::IsPsfFileName(const std::string_view& path) +bool System::IsPsfFileName(std::string_view path) { return (StringUtil::EndsWithNoCase(path, ".psf") || StringUtil::EndsWithNoCase(path, ".minipsf")); } -bool System::IsLoadableFilename(const std::string_view& path) +bool System::IsLoadableFilename(std::string_view path) { static constexpr const std::array extensions = { ".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs @@ -570,7 +570,7 @@ bool System::IsLoadableFilename(const std::string_view& path) return false; } -bool System::IsSaveStateFilename(const std::string_view& path) +bool System::IsSaveStateFilename(std::string_view path) { return StringUtil::EndsWithNoCase(path, ".sav"); } @@ -907,13 +907,13 @@ std::optional System::GetRegionForPath(const char* image_path) return GetRegionForImage(cdi.get()); } -std::string System::GetGameSettingsPath(const std::string_view& game_serial) +std::string System::GetGameSettingsPath(std::string_view game_serial) { const std::string sanitized_serial(Path::SanitizeFileName(game_serial)); return Path::Combine(EmuFolders::GameSettings, fmt::format("{}.ini", sanitized_serial)); } -std::string System::GetInputProfilePath(const std::string_view& name) +std::string System::GetInputProfilePath(std::string_view name) { return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name)); } @@ -3614,7 +3614,7 @@ u32 System::GetMediaSubImageIndex() return cdi ? cdi->GetCurrentSubImage() : 0; } -u32 System::GetMediaSubImageIndexForTitle(const std::string_view& title) +u32 System::GetMediaSubImageIndexForTitle(std::string_view title) { const CDImage* cdi = CDROM::GetMedia(); if (!cdi) @@ -4533,7 +4533,7 @@ bool System::SaveScreenshot(const char* filename, DisplayScreenshotMode mode, Di return g_gpu->RenderScreenshotToFile(filename, mode, quality, compress_on_thread, true); } -std::string System::GetGameSaveStateFileName(const std::string_view& serial, s32 slot) +std::string System::GetGameSaveStateFileName(std::string_view serial, s32 slot) { if (slot < 0) return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_resume.sav", serial)); diff --git a/src/core/system.h b/src/core/system.h index b037738e6..39927f5d6 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -112,16 +112,16 @@ using GameHash = u64; extern TickCount g_ticks_per_second; /// Returns true if the filename is a PlayStation executable we can inject. -bool IsExeFileName(const std::string_view& path); +bool IsExeFileName(std::string_view path); /// Returns true if the filename is a Portable Sound Format file we can uncompress/load. -bool IsPsfFileName(const std::string_view& path); +bool IsPsfFileName(std::string_view path); /// Returns true if the filename is one we can load. -bool IsLoadableFilename(const std::string_view& path); +bool IsLoadableFilename(std::string_view path); /// Returns true if the filename is a save state. -bool IsSaveStateFilename(const std::string_view& path); +bool IsSaveStateFilename(std::string_view path); /// Returns the preferred console type for a disc. ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region); @@ -139,10 +139,10 @@ DiscRegion GetRegionForPsf(const char* path); std::optional GetRegionForPath(const char* image_path); /// Returns the path for the game settings ini file for the specified serial. -std::string GetGameSettingsPath(const std::string_view& game_serial); +std::string GetGameSettingsPath(std::string_view game_serial); /// 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(std::string_view name); State GetState(); void SetState(State new_state); @@ -332,7 +332,7 @@ u32 GetMediaSubImageCount(); u32 GetMediaSubImageIndex(); /// Returns the index of the specified path in the playlist, or UINT32_MAX if it does not exist. -u32 GetMediaSubImageIndexForTitle(const std::string_view& title); +u32 GetMediaSubImageIndexForTitle(std::string_view title); /// Returns the path to the specified playlist index. std::string GetMediaSubImageTitle(u32 index); @@ -374,7 +374,7 @@ void DoFrameStep(); void DoToggleCheats(); /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. -std::string GetGameSaveStateFileName(const std::string_view& serial, s32 slot); +std::string GetGameSaveStateFileName(std::string_view serial, s32 slot); /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. std::string GetGlobalSaveStateFileName(s32 slot); diff --git a/src/core/texture_replacements.cpp b/src/core/texture_replacements.cpp index 153698c4e..fe3d56596 100644 --- a/src/core/texture_replacements.cpp +++ b/src/core/texture_replacements.cpp @@ -45,7 +45,7 @@ std::string TextureReplacementHash::ToString() const return StringUtil::StdStringFromFormat("%" PRIx64 "%" PRIx64, high, low); } -bool TextureReplacementHash::ParseString(const std::string_view& sv) +bool TextureReplacementHash::ParseString(std::string_view sv) { if (sv.length() != 32) return false; diff --git a/src/core/texture_replacements.h b/src/core/texture_replacements.h index f713f58f2..69abf5c16 100644 --- a/src/core/texture_replacements.h +++ b/src/core/texture_replacements.h @@ -20,7 +20,7 @@ struct TextureReplacementHash u64 high; std::string ToString() const; - bool ParseString(const std::string_view& sv); + bool ParseString(std::string_view sv); bool operator<(const TextureReplacementHash& rhs) const { return std::tie(low, high) < std::tie(rhs.low, rhs.high); } bool operator==(const TextureReplacementHash& rhs) const { return low == rhs.low && high == rhs.high; } diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 35fa6a41e..637f8b791 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -1699,7 +1699,7 @@ void EmuThread::wakeThread() QMetaObject::invokeMethod(m_event_loop, "quit", Qt::QueuedConnection); } -void Host::ReportFatalError(const std::string_view& title, const std::string_view& message) +void Host::ReportFatalError(std::string_view title, std::string_view message) { auto cb = [title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message)]() { QMessageBox::critical(g_main_window && g_main_window->isVisible() ? g_main_window : nullptr, title, message); @@ -1727,7 +1727,7 @@ void Host::ReportFatalError(const std::string_view& title, const std::string_vie } } -void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) +void Host::ReportErrorAsync(std::string_view title, std::string_view message) { if (!title.empty() && !message.empty()) { @@ -1745,7 +1745,7 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie 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(std::string_view title, std::string_view message) { auto lock = g_emu_thread->pauseAndLockSystem(); @@ -1753,12 +1753,12 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& QString::fromUtf8(message.data(), message.size())); } -void Host::OpenURL(const std::string_view& url) +void Host::OpenURL(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(std::string_view text) { QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() { QClipboard* clipboard = QGuiApplication::clipboard(); @@ -1768,7 +1768,7 @@ bool Host::CopyTextToClipboard(const std::string_view& text) return true; } -void Host::ReportDebuggerMessage(const std::string_view& message) +void Host::ReportDebuggerMessage(std::string_view message) { emit g_emu_thread->debuggerMessageReported(QString::fromUtf8(message)); } @@ -1777,14 +1777,14 @@ void Host::AddFixedInputBindings(SettingsInterface& si) { } -void Host::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) +void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name) { emit g_emu_thread->onInputDeviceConnected( identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()), device_name.empty() ? QString() : QString::fromUtf8(device_name.data(), device_name.size())); } -void Host::OnInputDeviceDisconnected(const std::string_view& identifier) +void Host::OnInputDeviceDisconnected(std::string_view identifier) { emit g_emu_thread->onInputDeviceDisconnected( identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size())); diff --git a/src/duckstation-qt/qtkeycodes.cpp b/src/duckstation-qt/qtkeycodes.cpp index 2a8c9f610..76871f7ad 100644 --- a/src/duckstation-qt/qtkeycodes.cpp +++ b/src/duckstation-qt/qtkeycodes.cpp @@ -458,7 +458,7 @@ static constexpr KeyCodeName s_qt_key_names[] = {{Qt::Key_Escape, "Escape", ICON {Qt::Key_Camera, "Camera", nullptr}, {Qt::Key_CameraFocus, "CameraFocus", nullptr}}; -std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) +std::optional InputManager::ConvertHostKeyboardStringToCode(std::string_view str) { std::string_view compare_name = str; u32 modifier_bits = 0; diff --git a/src/duckstation-qt/qttranslations.cpp b/src/duckstation-qt/qttranslations.cpp index ea133de7c..9d4cc205c 100644 --- a/src/duckstation-qt/qttranslations.cpp +++ b/src/duckstation-qt/qttranslations.cpp @@ -55,10 +55,10 @@ struct GlyphInfo }; static QString FixLanguageName(const QString& language); -static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language); +static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, std::string_view language); static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const char* font_url, const std::string& path); -static const GlyphInfo* GetGlyphInfo(const std::string_view& language); +static const GlyphInfo* GetGlyphInfo(std::string_view language); static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf"; #define MAKE_FONT_DOWNLOAD_URL(name) "https://www.duckstation.org/runtime-resources/fonts/" name @@ -156,7 +156,7 @@ QString QtHost::FixLanguageName(const QString& language) return language; } -s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, +s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space) { // This is really awful. Thankfully we're caching the results... @@ -220,7 +220,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, std::string_view language) { const GlyphInfo* gi = GetGlyphInfo(language); @@ -357,7 +357,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(std::string_view language) { for (const GlyphInfo& it : s_glyph_info) { diff --git a/src/duckstation-qt/qtutils.cpp b/src/duckstation-qt/qtutils.cpp index d51df44a1..e1028365d 100644 --- a/src/duckstation-qt/qtutils.cpp +++ b/src/duckstation-qt/qtutils.cpp @@ -205,7 +205,7 @@ std::optional PromptForAddress(QWidget* parent, const QString& title, return address; } -QString StringViewToQString(const std::string_view& str) +QString StringViewToQString(std::string_view str) { return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size()); } diff --git a/src/duckstation-qt/qtutils.h b/src/duckstation-qt/qtutils.h index 291f82ae8..79647aa2f 100644 --- a/src/duckstation-qt/qtutils.h +++ b/src/duckstation-qt/qtutils.h @@ -93,7 +93,7 @@ void OpenURL(QWidget* parent, const char* url); std::optional PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code); /// Converts a std::string_view to a QString safely. -QString StringViewToQString(const std::string_view& str); +QString StringViewToQString(std::string_view str); /// Sets a widget to italics if the setting value is inherited. void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited); diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index 556782798..cc6443026 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -116,13 +116,13 @@ bool RegTestHost::InitializeConfig() return true; } -void Host::ReportFatalError(const std::string_view& title, const std::string_view& message) +void Host::ReportFatalError(std::string_view title, std::string_view message) { Log_ErrorPrintf("ReportFatalError: %.*s", static_cast(message.size()), message.data()); abort(); } -void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) +void Host::ReportErrorAsync(std::string_view title, std::string_view message) { if (!title.empty() && !message.empty()) { @@ -135,7 +135,7 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie } } -bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) +bool Host::ConfirmMessage(std::string_view title, std::string_view message) { if (!title.empty() && !message.empty()) { @@ -150,7 +150,7 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& return true; } -void Host::ReportDebuggerMessage(const std::string_view& message) +void Host::ReportDebuggerMessage(std::string_view message) { Log_ErrorPrintf("ReportDebuggerMessage: %.*s", static_cast(message.size()), message.data()); } @@ -165,7 +165,7 @@ bool Host::ChangeLanguage(const char* new_language) return false; } -s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, +s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space) { if (msg.size() > tbuf_space) @@ -347,12 +347,12 @@ void Host::BeginPresentFrame() } } -void Host::OpenURL(const std::string_view& url) +void Host::OpenURL(std::string_view url) { // } -bool Host::CopyTextToClipboard(const std::string_view& text) +bool Host::CopyTextToClipboard(std::string_view text) { return false; } @@ -387,7 +387,7 @@ void Host::OnCoverDownloaderOpenRequested() // noop } -std::optional InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) +std::optional InputManager::ConvertHostKeyboardStringToCode(std::string_view str) { return std::nullopt; } @@ -407,12 +407,12 @@ void Host::AddFixedInputBindings(SettingsInterface& si) // noop } -void Host::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) +void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name) { // noop } -void Host::OnInputDeviceDisconnected(const std::string_view& identifier) +void Host::OnInputDeviceDisconnected(std::string_view identifier) { // noop } diff --git a/src/util/cd_image.cpp b/src/util/cd_image.cpp index 339df124c..93b06fe5d 100644 --- a/src/util/cd_image.cpp +++ b/src/util/cd_image.cpp @@ -346,7 +346,7 @@ bool CDImage::HasNonStandardSubchannel() const return false; } -std::string CDImage::GetMetadata(const std::string_view& type) const +std::string CDImage::GetMetadata(std::string_view type) const { std::string result; if (type == "title") @@ -378,7 +378,7 @@ bool CDImage::SwitchSubImage(u32 index, Error* error) return false; } -std::string CDImage::GetSubImageMetadata(u32 index, const std::string_view& type) const +std::string CDImage::GetSubImageMetadata(u32 index, std::string_view type) const { return {}; } diff --git a/src/util/cd_image.h b/src/util/cd_image.h index f73b57e3f..37ce92061 100644 --- a/src/util/cd_image.h +++ b/src/util/cd_image.h @@ -307,7 +307,7 @@ public: virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0; // Retrieve image metadata. - virtual std::string GetMetadata(const std::string_view& type) const; + virtual std::string GetMetadata(std::string_view type) const; // Returns true if this image type has sub-images (e.g. m3u). virtual bool HasSubImages() const; @@ -322,7 +322,7 @@ public: virtual bool SwitchSubImage(u32 index, Error* error); // Retrieve sub-image metadata. - virtual std::string GetSubImageMetadata(u32 index, const std::string_view& type) const; + virtual std::string GetSubImageMetadata(u32 index, std::string_view type) const; // Returns true if the source supports precaching, which may be more optimal than an in-memory copy. virtual PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback); diff --git a/src/util/cd_image_hasher.cpp b/src/util/cd_image_hasher.cpp index fdf5f9ade..f60052eea 100644 --- a/src/util/cd_image_hasher.cpp +++ b/src/util/cd_image_hasher.cpp @@ -95,7 +95,7 @@ std::string CDImageHasher::HashToString(const Hash& hash) hash[11], hash[12], hash[13], hash[14], hash[15]); } -std::optional CDImageHasher::HashFromString(const std::string_view& str) +std::optional CDImageHasher::HashFromString(std::string_view str) { auto decoded = StringUtil::DecodeHex(str); if (decoded && decoded->size() == std::tuple_size_v) diff --git a/src/util/cd_image_hasher.h b/src/util/cd_image_hasher.h index 27728bd32..70b69ef5b 100644 --- a/src/util/cd_image_hasher.h +++ b/src/util/cd_image_hasher.h @@ -14,7 +14,7 @@ namespace CDImageHasher { using Hash = std::array; std::string HashToString(const Hash& hash); -std::optional HashFromString(const std::string_view& str); +std::optional HashFromString(std::string_view str); bool GetImageHash(CDImage* image, Hash* out_hash, ProgressCallback* progress_callback = ProgressCallback::NullProgressCallback); diff --git a/src/util/cd_image_m3u.cpp b/src/util/cd_image_m3u.cpp index 2fb2cc839..f52a65ff6 100644 --- a/src/util/cd_image_m3u.cpp +++ b/src/util/cd_image_m3u.cpp @@ -33,7 +33,7 @@ public: bool HasSubImages() const override; u32 GetSubImageCount() const override; u32 GetCurrentSubImage() const override; - std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; + std::string GetSubImageMetadata(u32 index, std::string_view type) const override; bool SwitchSubImage(u32 index, Error* error) override; protected: @@ -159,7 +159,7 @@ bool CDImageM3u::SwitchSubImage(u32 index, Error* error) return true; } -std::string CDImageM3u::GetSubImageMetadata(u32 index, const std::string_view& type) const +std::string CDImageM3u::GetSubImageMetadata(u32 index, std::string_view type) const { if (index > m_entries.size()) return {}; diff --git a/src/util/cd_image_pbp.cpp b/src/util/cd_image_pbp.cpp index fdbeeded5..1d08ce372 100644 --- a/src/util/cd_image_pbp.cpp +++ b/src/util/cd_image_pbp.cpp @@ -141,8 +141,8 @@ public: u32 GetSubImageCount() const override; u32 GetCurrentSubImage() const override; bool SwitchSubImage(u32 index, Error* error) override; - std::string GetMetadata(const std::string_view& type) const override; - std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; + std::string GetMetadata(std::string_view type) const override; + std::string GetSubImageMetadata(u32 index, std::string_view type) const override; protected: bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override; @@ -915,7 +915,7 @@ bool CDImagePBP::HasSubImages() const return m_disc_offsets.size() > 1; } -std::string CDImagePBP::GetMetadata(const std::string_view& type) const +std::string CDImagePBP::GetMetadata(std::string_view type) const { if (type == "title") { @@ -953,7 +953,7 @@ bool CDImagePBP::SwitchSubImage(u32 index, Error* error) return true; } -std::string CDImagePBP::GetSubImageMetadata(u32 index, const std::string_view& type) const +std::string CDImagePBP::GetSubImageMetadata(u32 index, std::string_view type) const { if (type == "title") { diff --git a/src/util/cd_image_ppf.cpp b/src/util/cd_image_ppf.cpp index a80b97ce4..5704eb016 100644 --- a/src/util/cd_image_ppf.cpp +++ b/src/util/cd_image_ppf.cpp @@ -35,8 +35,8 @@ public: bool HasNonStandardSubchannel() const override; s64 GetSizeOnDisk() const override; - std::string GetMetadata(const std::string_view& type) const override; - std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; + std::string GetMetadata(std::string_view type) const override; + std::string GetSubImageMetadata(u32 index, std::string_view type) const override; PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback) override; @@ -416,12 +416,12 @@ bool CDImagePPF::HasNonStandardSubchannel() const return m_parent_image->HasNonStandardSubchannel(); } -std::string CDImagePPF::GetMetadata(const std::string_view& type) const +std::string CDImagePPF::GetMetadata(std::string_view type) const { return m_parent_image->GetMetadata(type); } -std::string CDImagePPF::GetSubImageMetadata(u32 index, const std::string_view& type) const +std::string CDImagePPF::GetSubImageMetadata(u32 index, std::string_view type) const { // We only support a single sub-image for patched games. std::string ret; diff --git a/src/util/cue_parser.cpp b/src/util/cue_parser.cpp index b743a5cee..58c6f1249 100644 --- a/src/util/cue_parser.cpp +++ b/src/util/cue_parser.cpp @@ -12,10 +12,10 @@ Log_SetChannel(CueParser); namespace CueParser { -static bool TokenMatch(const std::string_view& s1, const char* token); +static bool TokenMatch(std::string_view s1, const char* token); } -bool CueParser::TokenMatch(const std::string_view& s1, const char* token) +bool CueParser::TokenMatch(std::string_view s1, const char* token) { const size_t token_len = std::strlen(token); if (s1.length() != token_len) @@ -124,7 +124,7 @@ std::string_view CueParser::File::GetToken(const char*& line) return ret; } -std::optional CueParser::File::GetMSF(const std::string_view& token) +std::optional CueParser::File::GetMSF(std::string_view token) { static const s32 max_values[] = {std::numeric_limits::max(), 60, 75}; diff --git a/src/util/cue_parser.h b/src/util/cue_parser.h index 050c65ee1..3b3d82f4f 100644 --- a/src/util/cue_parser.h +++ b/src/util/cue_parser.h @@ -68,7 +68,7 @@ private: void SetError(u32 line_number, Error* error, const char* format, ...); static std::string_view GetToken(const char*& line); - static std::optional GetMSF(const std::string_view& token); + static std::optional GetMSF(std::string_view token); bool ParseLine(const char* line, u32 line_number, Error* error); diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index ccbcc762b..b860bf629 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -31,7 +31,7 @@ static std::mutex s_instance_mutex; static constexpr std::array s_clear_color = {}; static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RGBA8; -void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name) +void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name) { #ifdef _DEBUG // WKPDID_D3DDebugObjectName @@ -64,7 +64,7 @@ bool D3D11Device::HasSurface() const return static_cast(m_swap_chain); } -bool D3D11Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation, +bool D3D11Device::CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { @@ -943,7 +943,8 @@ void D3D11Device::UnmapUniformBuffer(u32 size) } } -void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds, GPUPipeline::RenderPassFlag feedback_loop) +void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds, + GPUPipeline::RenderPassFlag feedback_loop) { ID3D11RenderTargetView* rtvs[MAX_RENDER_TARGETS]; DebugAssert(!feedback_loop); diff --git a/src/util/d3d11_device.h b/src/util/d3d11_device.h index d98861f10..e33884eb3 100644 --- a/src/util/d3d11_device.h +++ b/src/util/d3d11_device.h @@ -69,7 +69,7 @@ public: void InvalidateRenderTarget(GPUTexture* t) override; std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) override; - std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* binary) override; std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; @@ -111,7 +111,7 @@ public: static AdapterAndModeList StaticGetAdapterAndModeList(); protected: - bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) override; void DestroyDevice() override; @@ -204,4 +204,4 @@ private: float m_accumulated_gpu_time = 0.0f; }; -void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name); +void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name); diff --git a/src/util/d3d11_pipeline.cpp b/src/util/d3d11_pipeline.cpp index 299f3c50c..0bcced69d 100644 --- a/src/util/d3d11_pipeline.cpp +++ b/src/util/d3d11_pipeline.cpp @@ -46,7 +46,7 @@ ID3D11ComputeShader* D3D11Shader::GetComputeShader() const return static_cast(m_shader.Get()); } -void D3D11Shader::SetDebugName(const std::string_view& name) +void D3D11Shader::SetDebugName(std::string_view name) { SetD3DDebugObjectName(m_shader.Get(), name); } @@ -92,7 +92,7 @@ std::unique_ptr D3D11Device::CreateShaderFromBinary(GPUShaderStage st return std::unique_ptr(new D3D11Shader(stage, std::move(shader), std::move(bytecode))); } -std::unique_ptr D3D11Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr D3D11Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) { @@ -123,7 +123,7 @@ D3D11Pipeline::~D3D11Pipeline() D3D11Device::GetInstance().UnbindPipeline(this); } -void D3D11Pipeline::SetDebugName(const std::string_view& name) +void D3D11Pipeline::SetDebugName(std::string_view name) { // can't label this directly } diff --git a/src/util/d3d11_pipeline.h b/src/util/d3d11_pipeline.h index e23190103..1b78cfb77 100644 --- a/src/util/d3d11_pipeline.h +++ b/src/util/d3d11_pipeline.h @@ -30,7 +30,7 @@ public: ALWAYS_INLINE const std::vector& GetBytecode() const { return m_bytecode; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr shader, std::vector bytecode); @@ -49,7 +49,7 @@ class D3D11Pipeline final : public GPUPipeline public: ~D3D11Pipeline() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); } ALWAYS_INLINE ID3D11DepthStencilState* GetDepthStencilState() const { return m_ds.Get(); } diff --git a/src/util/d3d11_texture.cpp b/src/util/d3d11_texture.cpp index ae91c0b28..9a683e1aa 100644 --- a/src/util/d3d11_texture.cpp +++ b/src/util/d3d11_texture.cpp @@ -38,7 +38,7 @@ D3D11Sampler::D3D11Sampler(ComPtr ss) : m_ss(std::move(ss)) D3D11Sampler::~D3D11Sampler() = default; -void D3D11Sampler::SetDebugName(const std::string_view& name) +void D3D11Sampler::SetDebugName(std::string_view name) { SetD3DDebugObjectName(m_ss.Get(), name); } @@ -209,7 +209,7 @@ void D3D11Texture::Unmap() m_mapped_subresource = 0; } -void D3D11Texture::SetDebugName(const std::string_view& name) +void D3D11Texture::SetDebugName(std::string_view name) { SetD3DDebugObjectName(m_texture.Get(), name); } @@ -376,7 +376,7 @@ void D3D11TextureBuffer::Unmap(u32 used_elements) m_buffer.Unmap(D3D11Device::GetD3DContext(), size); } -void D3D11TextureBuffer::SetDebugName(const std::string_view& name) +void D3D11TextureBuffer::SetDebugName(std::string_view name) { SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name); } diff --git a/src/util/d3d11_texture.h b/src/util/d3d11_texture.h index d7fa6659b..55ceb8d65 100644 --- a/src/util/d3d11_texture.h +++ b/src/util/d3d11_texture.h @@ -26,7 +26,7 @@ public: ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); } ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D11Sampler(ComPtr ss); @@ -85,7 +85,7 @@ public: bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override; void Unmap() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format, @@ -113,7 +113,7 @@ public: void* Map(u32 required_elements) override; void Unmap(u32 used_elements) override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D11StreamBuffer m_buffer; diff --git a/src/util/d3d12_builders.cpp b/src/util/d3d12_builders.cpp index 94ce24ddc..93b2c32a3 100644 --- a/src/util/d3d12_builders.cpp +++ b/src/util/d3d12_builders.cpp @@ -336,7 +336,7 @@ u32 D3D12::RootSignatureBuilder::AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE #ifdef _DEBUG -void D3D12::SetObjectName(ID3D12Object* object, const std::string_view& name) +void D3D12::SetObjectName(ID3D12Object* object, std::string_view name) { object->SetName(StringUtil::UTF8StringToWideString(name).c_str()); } diff --git a/src/util/d3d12_builders.h b/src/util/d3d12_builders.h index 657c413cb..82bb776bb 100644 --- a/src/util/d3d12_builders.h +++ b/src/util/d3d12_builders.h @@ -126,10 +126,10 @@ private: }; #ifdef _DEBUG -void SetObjectName(ID3D12Object* object, const std::string_view& name); +void SetObjectName(ID3D12Object* object, std::string_view name); void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...); #else -static inline void SetObjectName(ID3D12Object* object, const std::string_view& name) +static inline void SetObjectName(ID3D12Object* object, std::string_view name) { } static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...) diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index cf2fae52d..e57cb7188 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -117,7 +117,7 @@ D3D12Device::ComPtr D3D12Device::CreateRootSignature(const return rs; } -bool D3D12Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation, +bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { diff --git a/src/util/d3d12_device.h b/src/util/d3d12_device.h index 668dff0a8..59e193698 100644 --- a/src/util/d3d12_device.h +++ b/src/util/d3d12_device.h @@ -91,7 +91,7 @@ public: void InvalidateRenderTarget(GPUTexture* t) override; std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) override; - std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) override; std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; @@ -180,7 +180,7 @@ public: void UnbindTextureBuffer(D3D12TextureBuffer* buf); protected: - bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) override; void DestroyDevice() override; diff --git a/src/util/d3d12_pipeline.cpp b/src/util/d3d12_pipeline.cpp index 318afb564..af52ab647 100644 --- a/src/util/d3d12_pipeline.cpp +++ b/src/util/d3d12_pipeline.cpp @@ -21,7 +21,7 @@ D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(st D3D12Shader::~D3D12Shader() = default; -void D3D12Shader::SetDebugName(const std::string_view& name) +void D3D12Shader::SetDebugName(std::string_view name) { } @@ -32,7 +32,7 @@ std::unique_ptr D3D12Device::CreateShaderFromBinary(GPUShaderStage st return std::unique_ptr(new D3D12Shader(stage, std::move(bytecode))); } -std::unique_ptr D3D12Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr D3D12Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) { @@ -63,7 +63,7 @@ D3D12Pipeline::~D3D12Pipeline() D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline)); } -void D3D12Pipeline::SetDebugName(const std::string_view& name) +void D3D12Pipeline::SetDebugName(std::string_view name) { D3D12::SetObjectName(m_pipeline.Get(), name); } diff --git a/src/util/d3d12_pipeline.h b/src/util/d3d12_pipeline.h index 68f99fdd8..2ba9e5ffb 100644 --- a/src/util/d3d12_pipeline.h +++ b/src/util/d3d12_pipeline.h @@ -25,7 +25,7 @@ public: ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); } ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast(m_bytecode.size()); } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D12Shader(GPUShaderStage stage, Bytecode bytecode); @@ -48,7 +48,7 @@ public: ALWAYS_INLINE const std::array& GetBlendConstantsF() const { return m_blend_constants_f; } ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; static std::string GetPipelineName(const GraphicsConfig& config); diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index f85b153a4..309f2cf12 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -591,7 +591,7 @@ void D3D12Texture::ActuallyCommitClear(ID3D12GraphicsCommandList* cmdlist) SetState(State::Dirty); } -void D3D12Texture::SetDebugName(const std::string_view& name) +void D3D12Texture::SetDebugName(std::string_view name) { D3D12::SetObjectName(m_resource.Get(), name); } @@ -673,7 +673,7 @@ D3D12Sampler::~D3D12Sampler() // Cleaned up by main class. } -void D3D12Sampler::SetDebugName(const std::string_view& name) +void D3D12Sampler::SetDebugName(std::string_view name) { } @@ -813,7 +813,7 @@ void D3D12TextureBuffer::Unmap(u32 used_elements) m_buffer.CommitMemory(size); } -void D3D12TextureBuffer::SetDebugName(const std::string_view& name) +void D3D12TextureBuffer::SetDebugName(std::string_view name) { D3D12::SetObjectName(m_buffer.GetBuffer(), name); } diff --git a/src/util/d3d12_texture.h b/src/util/d3d12_texture.h index 4186f4ad3..189de1400 100644 --- a/src/util/d3d12_texture.h +++ b/src/util/d3d12_texture.h @@ -42,7 +42,7 @@ public: void Unmap() override; void MakeReadyForSampling() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; void TransitionToState(D3D12_RESOURCE_STATES state); void CommitClear(); @@ -115,7 +115,7 @@ public: ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D12Sampler(D3D12DescriptorHandle descriptor); @@ -140,7 +140,7 @@ public: void* Map(u32 required_elements) override; void Unmap(u32 used_elements) override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: D3D12StreamBuffer m_buffer; diff --git a/src/util/d3d_common.cpp b/src/util/d3d_common.cpp index d1d4dab40..20561ae89 100644 --- a/src/util/d3d_common.cpp +++ b/src/util/d3d_common.cpp @@ -134,7 +134,7 @@ std::vector D3DCommon::GetAdapterNames(IDXGIFactory5* factory) return adapter_names; } -std::vector D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name) +std::vector D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, std::string_view adapter_name) { std::vector modes; HRESULT hr; @@ -250,7 +250,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, return true; } -Microsoft::WRL::ComPtr D3DCommon::GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name) +Microsoft::WRL::ComPtr D3DCommon::GetAdapterByName(IDXGIFactory5* factory, std::string_view name) { if (name.empty()) return {}; @@ -296,8 +296,7 @@ Microsoft::WRL::ComPtr D3DCommon::GetFirstAdapter(IDXGIFactory5* return adapter; } -Microsoft::WRL::ComPtr D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory, - const std::string_view& name) +Microsoft::WRL::ComPtr D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name) { Microsoft::WRL::ComPtr adapter = GetAdapterByName(factory, name); if (!adapter) @@ -374,7 +373,7 @@ std::string D3DCommon::GetDriverVersionFromLUID(const LUID& luid) } std::optional> D3DCommon::CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device, - GPUShaderStage stage, const std::string_view& source, + GPUShaderStage stage, std::string_view source, const char* entry_point) { const char* target; diff --git a/src/util/d3d_common.h b/src/util/d3d_common.h index f34f33cb9..14e7b2b8b 100644 --- a/src/util/d3d_common.h +++ b/src/util/d3d_common.h @@ -38,7 +38,7 @@ Microsoft::WRL::ComPtr CreateFactory(bool debug, Error* error); 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, 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, @@ -46,13 +46,13 @@ bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& IDXGIOutput** output); // get an adapter based on name -Microsoft::WRL::ComPtr GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name); +Microsoft::WRL::ComPtr GetAdapterByName(IDXGIFactory5* factory, std::string_view name); // returns the first adapter in the system Microsoft::WRL::ComPtr GetFirstAdapter(IDXGIFactory5* factory); // returns the adapter specified in the configuration, or the default -Microsoft::WRL::ComPtr GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name); +Microsoft::WRL::ComPtr GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name); // returns a utf-8 string of the specified adapter's name std::string GetAdapterName(IDXGIAdapter1* adapter); @@ -61,7 +61,7 @@ std::string GetAdapterName(IDXGIAdapter1* adapter); std::string GetDriverVersionFromLUID(const LUID& luid); std::optional> CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device, - GPUShaderStage stage, const std::string_view& source, + GPUShaderStage stage, std::string_view source, const char* entry_point); struct DXGIFormatMapping diff --git a/src/util/dinput_source.cpp b/src/util/dinput_source.cpp index d49053151..413140270 100644 --- a/src/util/dinput_source.cpp +++ b/src/util/dinput_source.cpp @@ -307,7 +307,7 @@ std::vector DInputSource::EnumerateMotors() return {}; } -bool DInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) +bool DInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) { return {}; } @@ -323,8 +323,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(std::string_view device, std::string_view binding) { if (!device.starts_with("DInput-") || binding.empty()) return std::nullopt; diff --git a/src/util/dinput_source.h b/src/util/dinput_source.h index def698ebb..0cf5f582f 100644 --- a/src/util/dinput_source.h +++ b/src/util/dinput_source.h @@ -41,13 +41,12 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(std::string_view device, 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(std::string_view device, std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override; diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index 832ad4389..d94762505 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -270,8 +270,8 @@ bool GPUDevice::IsSameRenderAPI(RenderAPI lhs, RenderAPI rhs) (rhs == RenderAPI::OpenGL || rhs == RenderAPI::OpenGLES))); } -bool GPUDevice::Create(const std::string_view& adapter, const std::string_view& shader_cache_path, - u32 shader_cache_version, bool debug_device, bool vsync, bool threaded_presentation, +bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version, + bool debug_device, bool vsync, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { m_vsync_enabled = vsync; @@ -318,7 +318,7 @@ bool GPUDevice::SupportsExclusiveFullscreen() const return false; } -void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version) +void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version) { if (m_features.shader_cache && !base_path.empty()) { @@ -388,7 +388,7 @@ void GPUDevice::CloseShaderCache() } } -std::string GPUDevice::GetShaderCacheBaseName(const std::string_view& type) const +std::string GPUDevice::GetShaderCacheBaseName(std::string_view type) const { const std::string_view debug_suffix = m_debug_device ? "_debug" : ""; @@ -641,7 +641,7 @@ void GPUDevice::InvalidateRenderTarget(GPUTexture* t) t->SetState(GPUTexture::State::Invalidated); } -std::unique_ptr GPUDevice::CreateShader(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr GPUDevice::CreateShader(GPUShaderStage stage, std::string_view source, const char* entry_point /* = "main" */) { std::unique_ptr shader; @@ -730,7 +730,7 @@ std::string GPUDevice::GetFullscreenModeString(u32 width, u32 height, float refr return fmt::format("{} x {} @ {} hz", width, height, refresh_rate); } -std::string GPUDevice::GetShaderDumpPath(const std::string_view& name) +std::string GPUDevice::GetShaderDumpPath(std::string_view name) { return Path::Combine(EmuFolders::Dumps, name); } diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index 53fb74f79..8790d3dd5 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -88,7 +88,7 @@ public: GPUSampler(); virtual ~GPUSampler(); - virtual void SetDebugName(const std::string_view& name) = 0; + virtual void SetDebugName(std::string_view name) = 0; static Config GetNearestConfig(); static Config GetLinearConfig(); @@ -114,7 +114,7 @@ public: ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; } - virtual void SetDebugName(const std::string_view& name) = 0; + virtual void SetDebugName(std::string_view name) = 0; protected: GPUShaderStage m_stage; @@ -397,7 +397,7 @@ public: GPUPipeline(); virtual ~GPUPipeline(); - virtual void SetDebugName(const std::string_view& name) = 0; + virtual void SetDebugName(std::string_view name) = 0; }; class GPUTextureBuffer @@ -423,7 +423,7 @@ public: virtual void* Map(u32 required_elements) = 0; virtual void Unmap(u32 used_elements) = 0; - virtual void SetDebugName(const std::string_view& name) = 0; + virtual void SetDebugName(std::string_view name) = 0; protected: Format m_format; @@ -527,7 +527,7 @@ public: static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate); /// Returns the directory bad shaders are saved to. - static std::string GetShaderDumpPath(const std::string_view& name); + static std::string GetShaderDumpPath(std::string_view name); /// Dumps out a shader that failed compilation. static void DumpBadShader(std::string_view code, std::string_view errors); @@ -572,9 +572,9 @@ public: virtual RenderAPI GetRenderAPI() const = 0; - bool Create(const std::string_view& adapter, const std::string_view& shader_cache_path, u32 shader_cache_version, - bool debug_device, bool vsync, bool threaded_presentation, - std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error); + bool Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version, bool debug_device, + bool vsync, bool threaded_presentation, std::optional exclusive_fullscreen_control, + FeatureMask disabled_features, Error* error); void Destroy(); virtual bool HasSurface() const = 0; @@ -622,7 +622,7 @@ public: virtual void InvalidateRenderTarget(GPUTexture* t); /// Shader abstraction. - std::unique_ptr CreateShader(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShader(GPUShaderStage stage, std::string_view source, const char* entry_point = "main"); virtual std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) = 0; @@ -701,17 +701,17 @@ public: static void ResetStatistics(); protected: - virtual bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + virtual bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) = 0; virtual void DestroyDevice() = 0; - std::string GetShaderCacheBaseName(const std::string_view& type) const; + std::string GetShaderCacheBaseName(std::string_view type) const; virtual bool ReadPipelineCache(const std::string& filename); virtual bool GetPipelineCacheData(DynamicHeapArray* data); virtual std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) = 0; - virtual std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + virtual std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) = 0; @@ -764,7 +764,7 @@ private: using TexturePool = std::deque; - void OpenShaderCache(const std::string_view& base_path, u32 version); + void OpenShaderCache(std::string_view base_path, u32 version); void CloseShaderCache(); bool CreateResources(); void DestroyResources(); diff --git a/src/util/gpu_shader_cache.cpp b/src/util/gpu_shader_cache.cpp index 5638acf53..41385fb5d 100644 --- a/src/util/gpu_shader_cache.cpp +++ b/src/util/gpu_shader_cache.cpp @@ -56,7 +56,7 @@ std::size_t GPUShaderCache::CacheIndexEntryHash::operator()(const CacheIndexKey& return h; } -bool GPUShaderCache::Open(const std::string_view& base_filename, u32 version) +bool GPUShaderCache::Open(std::string_view base_filename, u32 version) { m_base_filename = base_filename; m_version = version; @@ -214,8 +214,8 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std:: return true; } -GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code, - const std::string_view& entry_point) +GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, std::string_view shader_code, + std::string_view entry_point) { union { diff --git a/src/util/gpu_shader_cache.h b/src/util/gpu_shader_cache.h index 032aea29b..058170d2d 100644 --- a/src/util/gpu_shader_cache.h +++ b/src/util/gpu_shader_cache.h @@ -46,12 +46,11 @@ public: bool IsOpen() const { return (m_index_file != nullptr); } - bool Open(const std::string_view& base_filename, u32 version); + bool Open(std::string_view base_filename, u32 version); bool Create(); void Close(); - static CacheIndexKey GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code, - const std::string_view& entry_point); + static CacheIndexKey GetCacheKey(GPUShaderStage stage, std::string_view shader_code, std::string_view entry_point); bool Lookup(const CacheIndexKey& key, ShaderBinary* binary); bool Insert(const CacheIndexKey& key, const void* data, u32 data_size); diff --git a/src/util/gpu_texture.h b/src/util/gpu_texture.h index a7dafccf2..496be5686 100644 --- a/src/util/gpu_texture.h +++ b/src/util/gpu_texture.h @@ -156,7 +156,7 @@ public: // Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout. virtual void MakeReadyForSampling(); - virtual void SetDebugName(const std::string_view& name) = 0; + virtual void SetDebugName(std::string_view name) = 0; protected: GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format); diff --git a/src/util/host.cpp b/src/util/host.cpp index 053a4d0f6..8429bd7e0 100644 --- a/src/util/host.cpp +++ b/src/util/host.cpp @@ -14,8 +14,7 @@ Log_SetChannel(Host); namespace Host { -static std::pair LookupTranslationString(const std::string_view& context, - const std::string_view& msg); +static std::pair LookupTranslationString(std::string_view context, std::string_view msg); static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024; using TranslationStringMap = PreferUnorderedStringMap>; @@ -26,7 +25,7 @@ static std::vector s_translation_string_cache; 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(std::string_view context, std::string_view msg) { // TODO: TranslatableString, compile-time hashing. @@ -103,18 +102,18 @@ add_string: return ret; } -const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg) +const char* Host::TranslateToCString(std::string_view context, 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(std::string_view context, 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(std::string_view context, std::string_view msg) { return std::string(TranslateToStringView(context, msg)); } @@ -127,7 +126,7 @@ void Host::ClearTranslationCache() s_translation_string_mutex.unlock(); } -void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...) +void Host::ReportFormattedErrorAsync(std::string_view title, const char* format, ...) { std::va_list ap; va_start(ap, format); @@ -136,7 +135,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(std::string_view title, const char* format, ...) { std::va_list ap; va_start(ap, format); diff --git a/src/util/host.h b/src/util/host.h index 680f53f04..56a89ab8d 100644 --- a/src/util/host.h +++ b/src/util/host.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once @@ -27,45 +27,44 @@ std::optional GetResourceFileTimestamp(std::string_view filename, b /// Reports a fatal error on the main thread. This does not assume that the main window exists, /// unlike ReportErrorAsync(), and will exit the application after the popup is closed. -void ReportFatalError(const std::string_view& title, const std::string_view& message); +void ReportFatalError(std::string_view title, std::string_view message); /// 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(std::string_view title, std::string_view message); +void ReportFormattedErrorAsync(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(std::string_view title, std::string_view message); +bool ConfirmFormattedMessage(std::string_view title, const char* format, ...); /// Returns the user agent to use for HTTP requests. std::string GetHTTPUserAgent(); /// Opens a URL, using the default application. -void OpenURL(const std::string_view& url); +void OpenURL(std::string_view url); /// Copies the provided text to the host's clipboard, if present. -bool CopyTextToClipboard(const std::string_view& text); +bool CopyTextToClipboard(std::string_view text); /// 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(std::string_view context, 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(std::string_view context, 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(std::string_view context, std::string_view msg); /// Clears the translation cache. All previously used strings should be considered invalid. void ClearTranslationCache(); namespace Internal { /// 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(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space); } // namespace Internal } // namespace Host diff --git a/src/util/image.cpp b/src/util/image.cpp index dc5b884f1..7b77608ac 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -27,26 +27,26 @@ Log_SetChannel(Image); static bool PNGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool PNGBufferSaver(const RGBA8Image& image, std::vector* buffer, u8 quality); -static bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); -static bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); +static bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp); +static bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality); static bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool JPEGBufferSaver(const RGBA8Image& image, std::vector* buffer, u8 quality); -static bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); -static bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); +static bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp); +static bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality); static bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool WebPBufferSaver(const RGBA8Image& image, std::vector* buffer, u8 quality); -static bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); -static bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); +static bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp); +static bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality); struct FormatHandler { const char* extension; bool (*buffer_loader)(RGBA8Image*, const void*, size_t); bool (*buffer_saver)(const RGBA8Image&, std::vector*, u8); - bool (*file_loader)(RGBA8Image*, const char*, std::FILE*); - bool (*file_saver)(const RGBA8Image&, const char*, std::FILE*, u8); + bool (*file_loader)(RGBA8Image*, std::string_view, std::FILE*); + bool (*file_saver)(const RGBA8Image&, std::string_view, std::FILE*, u8); }; static constexpr FormatHandler s_format_handlers[] = { @@ -56,7 +56,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(std::string_view extension) { for (const FormatHandler& handler : s_format_handlers) { @@ -125,39 +125,39 @@ bool RGBA8Image::SaveToFile(const char* filename, u8 quality) const return false; } -bool RGBA8Image::LoadFromFile(const char* filename, std::FILE* fp) +bool RGBA8Image::LoadFromFile(std::string_view filename, std::FILE* fp) { const std::string_view extension(Path::GetExtension(filename)); const FormatHandler* handler = GetFormatHandler(extension); if (!handler || !handler->file_loader) { - Log_ErrorPrintf("Unknown extension '%.*s'", static_cast(extension.size()), extension.data()); + Log_ErrorFmt("Unknown extension '{}'", extension); return false; } return handler->file_loader(this, filename, fp); } -bool RGBA8Image::LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size) +bool RGBA8Image::LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size) { const std::string_view extension(Path::GetExtension(filename)); const FormatHandler* handler = GetFormatHandler(extension); if (!handler || !handler->buffer_loader) { - Log_ErrorPrintf("Unknown extension '%.*s'", static_cast(extension.size()), extension.data()); + Log_ErrorFmt("Unknown extension '{}'", extension); return false; } return handler->buffer_loader(this, buffer, buffer_size); } -bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) const +bool RGBA8Image::SaveToFile(std::string_view filename, std::FILE* fp, u8 quality) const { const std::string_view extension(Path::GetExtension(filename)); const FormatHandler* handler = GetFormatHandler(extension); if (!handler || !handler->file_saver) { - Log_ErrorPrintf("Unknown extension '%.*s'", static_cast(extension.size()), extension.data()); + Log_ErrorFmt("Unknown extension '{}'", extension); return false; } @@ -167,7 +167,7 @@ bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) con return (std::fflush(fp) == 0); } -std::optional> RGBA8Image::SaveToBuffer(const char* filename, u8 quality) const +std::optional> RGBA8Image::SaveToBuffer(std::string_view filename, u8 quality) const { std::optional> ret; @@ -175,7 +175,7 @@ std::optional> RGBA8Image::SaveToBuffer(const char* filename, u8 const FormatHandler* handler = GetFormatHandler(extension); if (!handler || !handler->file_saver) { - Log_ErrorPrintf("Unknown extension '%.*s'", static_cast(extension.size()), extension.data()); + Log_ErrorFmt("Unknown extension '{}'", extension); return ret; } @@ -271,7 +271,7 @@ static bool PNGCommonLoader(RGBA8Image* image, png_structp png_ptr, png_infop in return true; } -bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) +bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp) { png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!png_ptr) @@ -356,7 +356,7 @@ static void PNGSaveCommon(const RGBA8Image& image, png_structp png_ptr, png_info png_write_end(png_ptr, nullptr); } -bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) +bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality) { png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_infop info_ptr = nullptr; @@ -521,7 +521,7 @@ bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size) }); } -bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) +bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp) { static constexpr u32 BUFFER_SIZE = 16384; @@ -671,7 +671,7 @@ bool JPEGBufferSaver(const RGBA8Image& image, std::vector* buffer, u8 qualit return WrapJPEGCompress(image, quality, [&cb](jpeg_compress_struct& info) { info.dest = &cb.mgr; }); } -bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) +bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality) { static constexpr u32 BUFFER_SIZE = 16384; @@ -755,7 +755,7 @@ bool WebPBufferSaver(const RGBA8Image& image, std::vector* buffer, u8 qualit return true; } -bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) +bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp) { std::optional> data = FileSystem::ReadBinaryFile(fp); if (!data.has_value()) @@ -764,7 +764,7 @@ bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) return WebPBufferLoader(image, data->data(), data->size()); } -bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) +bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality) { std::vector buffer; if (!WebPBufferSaver(image, &buffer, quality)) diff --git a/src/util/image.h b/src/util/image.h index a97389af9..adb2266cc 100644 --- a/src/util/image.h +++ b/src/util/image.h @@ -10,6 +10,7 @@ #include #include #include +#include #include template @@ -127,10 +128,10 @@ public: RGBA8Image& operator=(RGBA8Image&& move); bool LoadFromFile(const char* filename); - bool LoadFromFile(const char* filename, std::FILE* fp); - bool LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size); + bool LoadFromFile(std::string_view filename, std::FILE* fp); + bool LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size); bool SaveToFile(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const; - bool SaveToFile(const char* filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const; - std::optional> SaveToBuffer(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const; + bool SaveToFile(std::string_view filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const; + std::optional> SaveToBuffer(std::string_view filename, u8 quality = DEFAULT_SAVE_QUALITY) const; }; diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index 4fbbcd5bf..bb0dd2393 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -43,8 +43,8 @@ using MessageDialogCallbackVariant = std::variant LoadTextureImage(const char* path); -static std::shared_ptr UploadTexture(const char* path, const RGBA8Image& image); +static std::optional LoadTextureImage(std::string_view path); +static std::shared_ptr UploadTexture(std::string_view path, const RGBA8Image& image); static void TextureLoaderThread(); static void DrawFileSelector(); @@ -282,17 +282,18 @@ const std::shared_ptr& ImGuiFullscreen::GetPlaceholderTexture() return s_placeholder_texture; } -std::optional ImGuiFullscreen::LoadTextureImage(const char* path) +std::optional ImGuiFullscreen::LoadTextureImage(std::string_view path) { std::optional image; if (Path::IsAbsolute(path)) { Error error; - auto fp = FileSystem::OpenManagedCFile(path, "rb", &error); + std::string path_str(path); + auto fp = FileSystem::OpenManagedCFile(path_str.c_str(), "rb", &error); if (fp) { image = RGBA8Image(); - if (!image->LoadFromFile(path, fp.get())) + if (!image->LoadFromFile(path_str.c_str(), fp.get())) Log_ErrorFmt("Failed to read texture file '{}'", path); } else @@ -321,28 +322,27 @@ std::optional ImGuiFullscreen::LoadTextureImage(const char* path) return image; } -std::shared_ptr ImGuiFullscreen::UploadTexture(const char* path, const RGBA8Image& image) +std::shared_ptr ImGuiFullscreen::UploadTexture(std::string_view path, const RGBA8Image& image) { std::unique_ptr texture = g_gpu_device->FetchTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch()); if (!texture) { - Log_ErrorPrintf("failed to create %ux%u texture for resource", image.GetWidth(), image.GetHeight()); + Log_ErrorFmt("failed to create {}x{} texture for resource", image.GetWidth(), image.GetHeight()); return {}; } - Log_DevPrintf("Uploaded texture resource '%s' (%ux%u)", path, image.GetWidth(), image.GetHeight()); + Log_DevFmt("Uploaded texture resource '{}' ({}x{})", path, image.GetWidth(), image.GetHeight()); return std::shared_ptr(texture.release(), GPUDevice::PooledTextureDeleter()); } -std::shared_ptr ImGuiFullscreen::LoadTexture(const std::string_view& path) +std::shared_ptr ImGuiFullscreen::LoadTexture(std::string_view path) { - std::string path_str(path); - std::optional image(LoadTextureImage(path_str.c_str())); + std::optional image(LoadTextureImage(path)); if (image.has_value()) { - std::shared_ptr ret(UploadTexture(path_str.c_str(), image.value())); + std::shared_ptr ret(UploadTexture(path, image.value())); if (ret) return ret; } @@ -350,7 +350,7 @@ std::shared_ptr ImGuiFullscreen::LoadTexture(const std::string_view& return s_placeholder_texture; } -GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name) +GPUTexture* ImGuiFullscreen::GetCachedTexture(std::string_view name) { std::shared_ptr* tex_ptr = s_texture_cache.Lookup(name); if (!tex_ptr) @@ -362,7 +362,7 @@ GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name) return tex_ptr->get(); } -GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(const std::string_view& name) +GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(std::string_view name) { std::shared_ptr* tex_ptr = s_texture_cache.Lookup(name); if (!tex_ptr) diff --git a/src/util/imgui_fullscreen.h b/src/util/imgui_fullscreen.h index 3affef22a..1aa15e726 100644 --- a/src/util/imgui_fullscreen.h +++ b/src/util/imgui_fullscreen.h @@ -105,7 +105,7 @@ ALWAYS_INLINE static ImVec4 MulAlpha(const ImVec4& v, float a) return ImVec4(v.x, v.y, v.z, v.w * a); } -ALWAYS_INLINE static std::string_view RemoveHash(const std::string_view& s) +ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s) { const std::string_view::size_type pos = s.find('#'); return (pos != std::string_view::npos) ? s.substr(0, pos) : s; @@ -127,9 +127,9 @@ void Shutdown(); /// Texture cache. const std::shared_ptr& GetPlaceholderTexture(); -std::shared_ptr LoadTexture(const std::string_view& path); -GPUTexture* GetCachedTexture(const std::string_view& name); -GPUTexture* GetCachedTextureAsync(const std::string_view& name); +std::shared_ptr LoadTexture(std::string_view path); +GPUTexture* GetCachedTexture(std::string_view name); +GPUTexture* GetCachedTextureAsync(std::string_view name); bool InvalidateCachedTexture(const std::string& path); void UploadAsyncTextures(); diff --git a/src/util/input_manager.cpp b/src/util/input_manager.cpp index eb7c451f7..11463db75 100644 --- a/src/util/input_manager.cpp +++ b/src/util/input_manager.cpp @@ -98,16 +98,13 @@ struct MacroButton // Forward Declarations (for static qualifier) // ------------------------------------------------------------------------ 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 ParseSensorKey(const std::string_view& source, - const std::string_view& sub_binding); +static std::optional ParseHostKeyboardKey(std::string_view source, std::string_view sub_binding); +static std::optional ParsePointerKey(std::string_view source, std::string_view sub_binding); +static std::optional ParseSensorKey(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 std::vector SplitChord(std::string_view binding); +static bool SplitBinding(std::string_view binding, std::string_view* source, std::string_view* sub_binding); +static void PrettifyInputBindingPart(std::string_view binding, SmallString& ret, bool& changed); static void AddBindings(const std::vector& bindings, const InputEventHandler& handler); static bool IsAxisHandler(const InputEventHandler& handler); @@ -189,7 +186,7 @@ static std::vector> s_pointer_move_callbacks // Binding Parsing // ------------------------------------------------------------------------ -std::vector InputManager::SplitChord(const std::string_view& binding) +std::vector InputManager::SplitChord(std::string_view binding) { std::vector parts; @@ -219,8 +216,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(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) @@ -234,7 +230,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(std::string_view binding) { std::string_view source, sub_binding; if (!SplitBinding(binding, &source, &sub_binding)) @@ -269,7 +265,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(std::string_view binding, InputBindingKey* key, InputSource** source) { std::string_view source_string, sub_binding; if (!SplitBinding(binding, &source_string, &sub_binding)) @@ -486,7 +482,7 @@ void InputManager::AddBindings(const std::vector& bindings, const I AddBinding(binding, handler); } -void InputManager::AddBinding(const std::string_view& binding, const InputEventHandler& handler) +void InputManager::AddBinding(std::string_view binding, const InputEventHandler& handler) { std::shared_ptr ibinding; const std::vector chord_bindings(SplitChord(binding)); @@ -650,7 +646,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type) } } -std::optional InputManager::ParseInputSourceString(const std::string_view& str) +std::optional InputManager::ParseInputSourceString(std::string_view str) { for (u32 i = 0; i < static_cast(InputSourceType::Count); i++) { @@ -661,8 +657,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(std::string_view source, std::string_view sub_binding) { if (source != "Keyboard") return std::nullopt; @@ -677,8 +672,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(std::string_view source, std::string_view sub_binding) { const std::optional pointer_index = StringUtil::FromChars(source.substr(8)); if (!pointer_index.has_value() || pointer_index.value() < 0) @@ -731,7 +725,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(std::string_view source) { if (!source.starts_with("Pointer-")) return std::nullopt; @@ -748,8 +742,7 @@ std::string InputManager::GetPointerDeviceName(u32 pointer_index) return fmt::format("Pointer-{}", pointer_index); } -std::optional InputManager::ParseSensorKey(const std::string_view& source, - const std::string_view& sub_binding) +std::optional InputManager::ParseSensorKey(std::string_view source, std::string_view sub_binding) { if (source != "Sensor") return std::nullopt; @@ -1442,12 +1435,12 @@ std::vector InputManager::GetInputProfileNames() return ret; } -void InputManager::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) +void InputManager::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name) { Host::OnInputDeviceConnected(identifier, device_name); } -void InputManager::OnInputDeviceDisconnected(const std::string_view& identifier) +void InputManager::OnInputDeviceDisconnected(std::string_view identifier) { Host::OnInputDeviceDisconnected(identifier); } @@ -1873,7 +1866,7 @@ static void GetKeyboardGenericBindingMapping(std::vectoremplace_back(GenericInputBinding::R3, "Keyboard/4"); } -static bool GetInternalGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) +static bool GetInternalGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) { if (device == "Keyboard") { @@ -1884,7 +1877,7 @@ static bool GetInternalGenericBindingMapping(const std::string_view& device, Gen return false; } -GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view& device) +GenericInputBindingMapping InputManager::GetGenericBindingMapping(std::string_view device) { GenericInputBindingMapping mapping; diff --git a/src/util/input_manager.h b/src/util/input_manager.h index cdf9d3e69..378328001 100644 --- a/src/util/input_manager.h +++ b/src/util/input_manager.h @@ -194,16 +194,16 @@ const char* InputSourceToString(InputSourceType clazz); bool GetInputSourceDefaultEnabled(InputSourceType type); /// Parses an input class string. -std::optional ParseInputSourceString(const std::string_view& str); +std::optional ParseInputSourceString(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(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(std::string_view str); /// Converts a key code from an identifier to a human-readable string. std::optional ConvertHostKeyboardCodeToString(u32 code); @@ -225,7 +225,7 @@ InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis); InputBindingKey MakeSensorAxisKey(InputSubclass sensor, u32 axis); /// Parses an input binding key string. -std::optional ParseInputBindingKey(const std::string_view& binding); +std::optional ParseInputBindingKey(std::string_view binding); /// Converts a input key to a string. std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key); @@ -247,7 +247,7 @@ std::vector> EnumerateDevices(); std::vector EnumerateMotors(); /// Retrieves bindings that match the generic bindings for the specified device. -GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device); +GenericInputBindingMapping GetGenericBindingMapping(std::string_view device); /// Returns true if the specified input source is enabled. bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type); @@ -277,10 +277,10 @@ bool HasAnyBindingsForKey(InputBindingKey key); bool HasAnyBindingsForSource(InputBindingKey key); /// Parses a string binding into its components. Use with external AddBinding(). -bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source); +bool ParseBindingAndGetSource(std::string_view binding, InputBindingKey* key, InputSource** source); /// Externally adds a fixed binding. Be sure to call *after* ReloadBindings() otherwise it will be lost. -void AddBinding(const std::string_view& binding, const InputEventHandler& handler); +void AddBinding(std::string_view binding, const InputEventHandler& handler); /// Adds an external vibration binding. void AddVibrationBinding(u32 pad_index, const InputBindingKey* motor_0_binding, InputSource* motor_0_source, @@ -348,10 +348,10 @@ bool MapController(SettingsInterface& si, u32 controller, std::vector GetInputProfileNames(); /// Called when a new input device is connected. -void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name); +void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name); /// Called when an input device is disconnected. -void OnInputDeviceDisconnected(const std::string_view& identifier); +void OnInputDeviceDisconnected(std::string_view identifier); } // namespace InputManager namespace Host { @@ -359,10 +359,10 @@ namespace Host { void AddFixedInputBindings(SettingsInterface& si); /// Called when a new input device is connected. -void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name); +void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name); /// Called when an input device is disconnected. -void OnInputDeviceDisconnected(const std::string_view& identifier); +void OnInputDeviceDisconnected(std::string_view identifier); /// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates. void SetMouseMode(bool relative, bool hide_cursor); diff --git a/src/util/input_source.cpp b/src/util/input_source.cpp index b8e161f0b..73047ea9d 100644 --- a/src/util/input_source.cpp +++ b/src/util/input_source.cpp @@ -60,8 +60,8 @@ InputBindingKey InputSource::MakeGenericControllerMotorKey(InputSourceType clazz } std::optional InputSource::ParseGenericControllerKey(InputSourceType clazz, - const std::string_view& source, - const std::string_view& sub_binding) + std::string_view source, + 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/src/util/input_source.h b/src/util/input_source.h index 0f4846601..c0c088390 100644 --- a/src/util/input_source.h +++ b/src/util/input_source.h @@ -29,8 +29,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(std::string_view device, std::string_view binding) = 0; virtual TinyString ConvertKeyToString(InputBindingKey key) = 0; virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0; @@ -42,7 +41,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, GenericInputBindingMapping* mapping) = 0; + virtual bool GetGenericBindingMapping(std::string_view device, 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; @@ -65,8 +64,8 @@ public: static InputBindingKey MakeGenericControllerMotorKey(InputSourceType clazz, u32 controller_index, s32 motor_index); /// Parses a generic controller key string. - static std::optional ParseGenericControllerKey(InputSourceType clazz, const std::string_view& source, - const std::string_view& sub_binding); + static std::optional ParseGenericControllerKey(InputSourceType clazz, std::string_view source, + std::string_view sub_binding); /// Converts a generic controller key to a string. static std::string ConvertGenericControllerKeyToString(InputBindingKey key); diff --git a/src/util/iso_reader.cpp b/src/util/iso_reader.cpp index ab77a0d55..176dd7089 100644 --- a/src/util/iso_reader.cpp +++ b/src/util/iso_reader.cpp @@ -18,7 +18,7 @@ IsoReader::IsoReader() = default; IsoReader::~IsoReader() = default; -std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view& path) +std::string_view IsoReader::RemoveVersionIdentifierFromPath(std::string_view path) { const std::string_view::size_type pos = path.find(';'); return (pos != std::string_view::npos) ? path.substr(0, pos) : path; @@ -82,7 +82,7 @@ bool IsoReader::ReadPVD(Error* error) return false; } -std::optional IsoReader::LocateFile(const std::string_view& path, Error* error) +std::optional IsoReader::LocateFile(std::string_view path, Error* error) { const ISODirectoryEntry* root_de = reinterpret_cast(m_pvd.root_directory_entry); if (path.empty() || path == "/" || path == "\\") @@ -125,7 +125,7 @@ std::string_view IsoReader::GetDirectoryEntryFileName(const u8* sector, u32 de_s return std::string_view(str, length_without_version); } -std::optional IsoReader::LocateFile(const std::string_view& path, u8* sector_buffer, +std::optional IsoReader::LocateFile(std::string_view path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error) { @@ -206,7 +206,7 @@ std::optional IsoReader::LocateFile(const std::str return std::nullopt; } -std::vector IsoReader::GetFilesInDirectory(const std::string_view& path, Error* error) +std::vector IsoReader::GetFilesInDirectory(std::string_view path, Error* error) { std::string base_path(path); u32 directory_record_lsn; @@ -268,7 +268,7 @@ std::vector IsoReader::GetFilesInDirectory(const std::string_view& } std::vector> -IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*= nullptr*/) +IsoReader::GetEntriesInDirectory(std::string_view path, Error* error /*= nullptr*/) { std::string base_path(path); u32 directory_record_lsn; @@ -329,7 +329,7 @@ IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*= return files; } -bool IsoReader::FileExists(const std::string_view& path, Error* error) +bool IsoReader::FileExists(std::string_view path, Error* error) { auto de = LocateFile(path, error); if (!de) @@ -338,7 +338,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(std::string_view path, Error* error) { auto de = LocateFile(path, error); if (!de) @@ -347,7 +347,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(std::string_view path, std::vector* data, Error* error) { auto de = LocateFile(path, error); if (!de) diff --git a/src/util/iso_reader.h b/src/util/iso_reader.h index a3bba1af4..d4162667c 100644 --- a/src/util/iso_reader.h +++ b/src/util/iso_reader.h @@ -141,7 +141,7 @@ public: IsoReader(); ~IsoReader(); - static std::string_view RemoveVersionIdentifierFromPath(const std::string_view& path); + static std::string_view RemoveVersionIdentifierFromPath(std::string_view path); ALWAYS_INLINE const CDImage* GetImage() const { return m_image; } ALWAYS_INLINE u32 GetTrackNumber() const { return m_track_number; } @@ -150,15 +150,15 @@ public: bool Open(CDImage* image, u32 track_number, Error* error = nullptr); - std::vector GetFilesInDirectory(const std::string_view& path, Error* error = nullptr); - std::vector> GetEntriesInDirectory(const std::string_view& path, + std::vector GetFilesInDirectory(std::string_view path, Error* error = nullptr); + std::vector> GetEntriesInDirectory(std::string_view path, Error* error = nullptr); - std::optional LocateFile(const std::string_view& path, Error* error); + std::optional LocateFile(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(std::string_view path, Error* error = nullptr); + bool DirectoryExists(std::string_view path, Error* error = nullptr); + bool ReadFile(std::string_view path, std::vector* data, Error* error = nullptr); bool ReadFile(const ISODirectoryEntry& de, std::vector* data, Error* error = nullptr); private: @@ -167,7 +167,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, u32 directory_record_lba, + std::optional LocateFile(std::string_view path, u8* sector_buffer, u32 directory_record_lba, u32 directory_record_size, Error* error); CDImage* m_image; diff --git a/src/util/metal_device.h b/src/util/metal_device.h index 7a42a5b79..df2ed7388 100644 --- a/src/util/metal_device.h +++ b/src/util/metal_device.h @@ -45,7 +45,7 @@ public: ALWAYS_INLINE id GetSamplerState() const { return m_ss; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: MetalSampler(id ss); @@ -63,7 +63,7 @@ public: ALWAYS_INLINE id GetLibrary() const { return m_library; } ALWAYS_INLINE id GetFunction() const { return m_function; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: MetalShader(GPUShaderStage stage, id library, id function); @@ -84,7 +84,7 @@ public: ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; } ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: MetalPipeline(id pipeline, id depth, MTLCullMode cull_mode, @@ -114,7 +114,7 @@ public: void MakeReadyForSampling() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; // Call when the texture is bound to the pipeline, or read from in a copy. ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; } @@ -179,7 +179,7 @@ public: void* Map(u32 required_elements) override; void Unmap(u32 used_elements) override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: MetalStreamBuffer m_buffer; @@ -232,7 +232,7 @@ public: void InvalidateRenderTarget(GPUTexture* t) override; std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) override; - std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary = nullptr) override; std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; @@ -291,7 +291,7 @@ public: static AdapterAndModeList StaticGetAdapterAndModeList(); protected: - bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) override; void DestroyDevice() override; @@ -329,8 +329,8 @@ private: ClearPipelineConfig GetCurrentClearPipelineConfig() const; id GetClearDepthPipeline(const ClearPipelineConfig& config); - std::unique_ptr CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source, - const std::string_view& entry_point); + std::unique_ptr CreateShaderFromMSL(GPUShaderStage stage, std::string_view source, + std::string_view entry_point); id GetDepthState(const GPUPipeline::DepthState& ds); diff --git a/src/util/metal_device.mm b/src/util/metal_device.mm index f3d3654e0..013511a59 100644 --- a/src/util/metal_device.mm +++ b/src/util/metal_device.mm @@ -61,7 +61,7 @@ static constexpr std::array(GPUTexture::Format: static std::unique_ptr s_shaderc_compiler; -static NSString* StringViewToNSString(const std::string_view& str) +static NSString* StringViewToNSString(std::string_view str) { if (str.empty()) return nil; @@ -137,7 +137,7 @@ void MetalDevice::SetVSyncEnabled(bool enabled) [m_layer setDisplaySyncEnabled:enabled]; } -bool MetalDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation, +bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { @@ -592,7 +592,7 @@ MetalShader::~MetalShader() MetalDevice::DeferRelease(m_library); } -void MetalShader::SetDebugName(const std::string_view& name) +void MetalShader::SetDebugName(std::string_view name) { @autoreleasepool { @@ -604,7 +604,7 @@ void MetalShader::SetDebugName(const std::string_view& name) namespace EmuFolders { extern std::string DataRoot; } -static void DumpShader(u32 n, const std::string_view& suffix, const std::string_view& data) +static void DumpShader(u32 n, std::string_view suffix, std::string_view data) { if (data.empty()) return; @@ -617,8 +617,8 @@ static void DumpShader(u32 n, const std::string_view& suffix, const std::string_ std::fwrite(data.data(), data.length(), 1, fp.get()); } -std::unique_ptr MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source, - const std::string_view& entry_point) +std::unique_ptr MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, std::string_view source, + std::string_view entry_point) { @autoreleasepool { @@ -651,7 +651,7 @@ std::unique_ptr MetalDevice::CreateShaderFromBinary(GPUShaderStage st return CreateShaderFromMSL(stage, str_data, "main0"); } -std::unique_ptr MetalDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr MetalDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary /* = nullptr */) { @@ -839,7 +839,7 @@ MetalPipeline::~MetalPipeline() MetalDevice::DeferRelease(m_pipeline); } -void MetalPipeline::SetDebugName(const std::string_view& name) +void MetalPipeline::SetDebugName(std::string_view name) { // readonly property :/ } @@ -1188,7 +1188,7 @@ void MetalTexture::MakeReadyForSampling() dev.EndRenderPass(); } -void MetalTexture::SetDebugName(const std::string_view& name) +void MetalTexture::SetDebugName(std::string_view name) { @autoreleasepool { @@ -1434,7 +1434,7 @@ MetalSampler::MetalSampler(id ss) : m_ss(ss) MetalSampler::~MetalSampler() = default; -void MetalSampler::SetDebugName(const std::string_view& name) +void MetalSampler::SetDebugName(std::string_view name) { // lame.. have to put it on the descriptor :/ } @@ -1831,7 +1831,7 @@ void MetalTextureBuffer::Unmap(u32 used_elements) m_buffer.CommitMemory(size); } -void MetalTextureBuffer::SetDebugName(const std::string_view& name) +void MetalTextureBuffer::SetDebugName(std::string_view name) { @autoreleasepool { diff --git a/src/util/opengl_device.cpp b/src/util/opengl_device.cpp index ff8163ceb..cd89145b3 100644 --- a/src/util/opengl_device.cpp +++ b/src/util/opengl_device.cpp @@ -272,7 +272,7 @@ bool OpenGLDevice::HasSurface() const return m_window_info.type != WindowInfo::Type::Surfaceless; } -bool OpenGLDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation, +bool OpenGLDevice::CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { diff --git a/src/util/opengl_device.h b/src/util/opengl_device.h index 0d3051d74..2e5e1cae9 100644 --- a/src/util/opengl_device.h +++ b/src/util/opengl_device.h @@ -73,7 +73,7 @@ public: void InvalidateRenderTarget(GPUTexture* t) override; std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) override; - std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) override; std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; @@ -130,7 +130,7 @@ public: void UnbindPipeline(const OpenGLPipeline* pl); protected: - bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) override; void DestroyDevice() override; diff --git a/src/util/opengl_pipeline.cpp b/src/util/opengl_pipeline.cpp index d97e63631..f8f88a2e2 100644 --- a/src/util/opengl_pipeline.cpp +++ b/src/util/opengl_pipeline.cpp @@ -78,7 +78,7 @@ OpenGLShader::~OpenGLShader() glDeleteShader(m_id.value()); } -void OpenGLShader::SetDebugName(const std::string_view& name) +void OpenGLShader::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) @@ -163,7 +163,7 @@ std::unique_ptr OpenGLDevice::CreateShaderFromBinary(GPUShaderStage s return {}; } -std::unique_ptr OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) { @@ -440,7 +440,8 @@ void OpenGLDevice::UnrefProgram(const OpenGLPipeline::ProgramCacheKey& key) m_program_cache.erase(it); } -OpenGLPipeline::VertexArrayCache::const_iterator OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key) +OpenGLPipeline::VertexArrayCache::const_iterator +OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key) { OpenGLPipeline::VertexArrayCache::iterator it = m_vao_cache.find(key); if (it != m_vao_cache.end()) @@ -546,7 +547,7 @@ OpenGLPipeline::~OpenGLPipeline() dev.UnrefVAO(m_key.va_key); } -void OpenGLPipeline::SetDebugName(const std::string_view& name) +void OpenGLPipeline::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) diff --git a/src/util/opengl_pipeline.h b/src/util/opengl_pipeline.h index a936c5723..0e5ede7c0 100644 --- a/src/util/opengl_pipeline.h +++ b/src/util/opengl_pipeline.h @@ -16,7 +16,7 @@ class OpenGLShader final : public GPUShader public: ~OpenGLShader() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; bool Compile(); @@ -103,7 +103,7 @@ public: ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; } ALWAYS_INLINE GLenum GetTopology() const { return m_topology; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao, diff --git a/src/util/opengl_stream_buffer.cpp b/src/util/opengl_stream_buffer.cpp index 5bdaf9559..36f41f6df 100644 --- a/src/util/opengl_stream_buffer.cpp +++ b/src/util/opengl_stream_buffer.cpp @@ -29,7 +29,7 @@ void OpenGLStreamBuffer::Unbind() glBindBuffer(m_target, 0); } -void OpenGLStreamBuffer::SetDebugName(const std::string_view& name) +void OpenGLStreamBuffer::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) diff --git a/src/util/opengl_stream_buffer.h b/src/util/opengl_stream_buffer.h index 5a2c65d7f..6164b6dba 100644 --- a/src/util/opengl_stream_buffer.h +++ b/src/util/opengl_stream_buffer.h @@ -24,7 +24,7 @@ public: void Bind(); void Unbind(); - void SetDebugName(const std::string_view& name); + void SetDebugName(std::string_view name); struct MappingResult { diff --git a/src/util/opengl_texture.cpp b/src/util/opengl_texture.cpp index 9bc99ffd8..56ff66de1 100644 --- a/src/util/opengl_texture.cpp +++ b/src/util/opengl_texture.cpp @@ -350,7 +350,7 @@ void OpenGLTexture::Unmap() sb->Unbind(); } -void OpenGLTexture::SetDebugName(const std::string_view& name) +void OpenGLTexture::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) @@ -375,7 +375,7 @@ OpenGLSampler::~OpenGLSampler() OpenGLDevice::GetInstance().UnbindSampler(m_id); } -void OpenGLSampler::SetDebugName(const std::string_view& name) +void OpenGLSampler::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) @@ -660,7 +660,7 @@ void OpenGLTextureBuffer::Unmap(u32 used_elements) m_buffer->Unmap(size); } -void OpenGLTextureBuffer::SetDebugName(const std::string_view& name) +void OpenGLTextureBuffer::SetDebugName(std::string_view name) { #ifdef _DEBUG if (glObjectLabel) diff --git a/src/util/opengl_texture.h b/src/util/opengl_texture.h index f0bd6c11c..99aaeaabc 100644 --- a/src/util/opengl_texture.h +++ b/src/util/opengl_texture.h @@ -27,7 +27,7 @@ public: bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override; void Unmap() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; static std::unique_ptr Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format, const void* data = nullptr, u32 data_pitch = 0); @@ -73,7 +73,7 @@ public: void* Map(u32 required_elements) override; void Unmap(u32 used_elements) override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr buffer, @@ -92,7 +92,7 @@ public: ALWAYS_INLINE GLuint GetID() const { return m_id; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: OpenGLSampler(GLuint id); diff --git a/src/util/postprocessing.cpp b/src/util/postprocessing.cpp index e01d02e96..4014dac0a 100644 --- a/src/util/postprocessing.cpp +++ b/src/util/postprocessing.cpp @@ -33,7 +33,7 @@ Log_SetChannel(PostProcessing); namespace PostProcessing { template -static u32 ParseVector(const std::string_view& line, ShaderOption::ValueVector* values); +static u32 ParseVector(std::string_view line, ShaderOption::ValueVector* values); static TinyString ValueToString(ShaderOption::Type type, u32 vector_size, const ShaderOption::ValueVector& value); @@ -63,7 +63,7 @@ static std::unique_ptr s_dummy_texture; } // namespace PostProcessing template -u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::ValueVector* values) +u32 PostProcessing::ParseVector(std::string_view line, ShaderOption::ValueVector* values) { u32 index = 0; size_t start = 0; @@ -102,12 +102,12 @@ u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::Valu return size; } -u32 PostProcessing::ShaderOption::ParseFloatVector(const std::string_view& line, ValueVector* values) +u32 PostProcessing::ShaderOption::ParseFloatVector(std::string_view line, ValueVector* values) { return ParseVector(line, values); } -u32 PostProcessing::ShaderOption::ParseIntVector(const std::string_view& line, ValueVector* values) +u32 PostProcessing::ShaderOption::ParseIntVector(std::string_view line, ValueVector* values) { return ParseVector(line, values); } diff --git a/src/util/postprocessing.h b/src/util/postprocessing.h index fe1642e7d..1c4988807 100644 --- a/src/util/postprocessing.h +++ b/src/util/postprocessing.h @@ -63,8 +63,8 @@ struct ShaderOption ValueVector value; std::vector choice_options; - static u32 ParseIntVector(const std::string_view& line, ValueVector* values); - static u32 ParseFloatVector(const std::string_view& line, ValueVector* values); + static u32 ParseIntVector(std::string_view line, ValueVector* values); + static u32 ParseFloatVector(std::string_view line, ValueVector* values); static constexpr ValueVector MakeIntVector(s32 x, s32 y = 0, s32 z = 0, s32 w = 0) { diff --git a/src/util/postprocessing_shader.cpp b/src/util/postprocessing_shader.cpp index e16a4cd67..862e870e0 100644 --- a/src/util/postprocessing_shader.cpp +++ b/src/util/postprocessing_shader.cpp @@ -13,7 +13,7 @@ Log_SetChannel(PostProcessing); -void PostProcessing::Shader::ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value) +void PostProcessing::Shader::ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value) { size_t key_start = 0; while (key_start < line.size() && std::isspace(line[key_start])) @@ -105,7 +105,7 @@ void PostProcessing::Shader::LoadOptions(const SettingsInterface& si, const char } } -const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name) const +const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name) const { for (const ShaderOption& option : m_options) { @@ -116,7 +116,7 @@ const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(cons return nullptr; } -PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name) +PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name) { for (ShaderOption& option : m_options) { diff --git a/src/util/postprocessing_shader.h b/src/util/postprocessing_shader.h index e53530d0e..32e171636 100644 --- a/src/util/postprocessing_shader.h +++ b/src/util/postprocessing_shader.h @@ -41,8 +41,8 @@ public: std::vector TakeOptions(); void LoadOptions(const SettingsInterface& si, const char* section); - const ShaderOption* GetOptionByName(const std::string_view& name) const; - ShaderOption* GetOptionByName(const std::string_view& name); + const ShaderOption* GetOptionByName(std::string_view name) const; + ShaderOption* GetOptionByName(std::string_view name); virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0; @@ -52,7 +52,7 @@ public: s32 final_height, s32 orig_width, s32 orig_height, u32 target_width, u32 target_height) = 0; protected: - static void ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value); + static void ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value); virtual void OnOptionChanged(const ShaderOption& option); diff --git a/src/util/postprocessing_shader_fx.cpp b/src/util/postprocessing_shader_fx.cpp index b9aeabdd4..df82879f4 100644 --- a/src/util/postprocessing_shader_fx.cpp +++ b/src/util/postprocessing_shader_fx.cpp @@ -438,7 +438,7 @@ bool PostProcessing::ReShadeFXShader::CreateModule(s32 buffer_width, s32 buffer_ return true; } -static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view& annotation_name) +static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view annotation_name) { for (const reshadefx::annotation& an : uniform.annotations) { diff --git a/src/util/sdl_input_source.cpp b/src/util/sdl_input_source.cpp index c6973577e..a34e24fc5 100644 --- a/src/util/sdl_input_source.cpp +++ b/src/util/sdl_input_source.cpp @@ -243,7 +243,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(std::string_view str, u32 player_id) { if (player_id >= MAX_LED_COLORS) return 0; @@ -355,8 +355,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(std::string_view device, std::string_view binding) { if (!device.starts_with("SDL-") || binding.empty()) return std::nullopt; @@ -638,7 +637,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event) } } -SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view& device) +SDL_Joystick* SDLInputSource::GetJoystickForDevice(std::string_view device) { if (!device.starts_with("SDL-")) return nullptr; @@ -952,7 +951,7 @@ std::vector SDLInputSource::EnumerateMotors() return ret; } -bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) +bool SDLInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) { if (!device.starts_with("SDL-")) return false; diff --git a/src/util/sdl_input_source.h b/src/util/sdl_input_source.h index 25971c7ab..e33c5bda4 100644 --- a/src/util/sdl_input_source.h +++ b/src/util/sdl_input_source.h @@ -29,22 +29,21 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(std::string_view device, 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(std::string_view device, 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(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(std::string_view str, u32 player_id); static bool IsHandledInputEvent(const SDL_Event* ev); diff --git a/src/util/vulkan_builders.h b/src/util/vulkan_builders.h index fbcf7fd83..202cbcaaf 100644 --- a/src/util/vulkan_builders.h +++ b/src/util/vulkan_builders.h @@ -419,7 +419,7 @@ static inline void SetFormattedObjectName(VkDevice device, T object_handle, cons } template -static inline void SetObjectName(VkDevice device, T object_handle, const std::string_view& sv) +static inline void SetObjectName(VkDevice device, T object_handle, std::string_view sv) { #ifdef ENABLE_VULKAN_DEBUG_OBJECTS SetFormattedObjectName(device, object_handle, "%.*s", static_cast(sv.length()), sv.data()); diff --git a/src/util/vulkan_device.cpp b/src/util/vulkan_device.cpp index 9672e72ee..826d60ffb 100644 --- a/src/util/vulkan_device.cpp +++ b/src/util/vulkan_device.cpp @@ -1917,7 +1917,7 @@ bool VulkanDevice::HasSurface() const return static_cast(m_swap_chain); } -bool VulkanDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation, +bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) { diff --git a/src/util/vulkan_device.h b/src/util/vulkan_device.h index ed5d2d330..374f691cd 100644 --- a/src/util/vulkan_device.h +++ b/src/util/vulkan_device.h @@ -99,7 +99,7 @@ public: void InvalidateRenderTarget(GPUTexture* t) override; std::unique_ptr CreateShaderFromBinary(GPUShaderStage stage, std::span data) override; - std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, + std::unique_ptr CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) override; std::unique_ptr CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; @@ -221,7 +221,7 @@ public: void UnbindTextureBuffer(VulkanTextureBuffer* buf); protected: - bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, + bool CreateDevice(std::string_view adapter, bool threaded_presentation, std::optional exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) override; void DestroyDevice() override; diff --git a/src/util/vulkan_pipeline.cpp b/src/util/vulkan_pipeline.cpp index a0a68d3ce..434764a5d 100644 --- a/src/util/vulkan_pipeline.cpp +++ b/src/util/vulkan_pipeline.cpp @@ -23,7 +23,7 @@ VulkanShader::~VulkanShader() vkDestroyShaderModule(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, nullptr); } -void VulkanShader::SetDebugName(const std::string_view& name) +void VulkanShader::SetDebugName(std::string_view name) { Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name); } @@ -44,7 +44,7 @@ std::unique_ptr VulkanDevice::CreateShaderFromBinary(GPUShaderStage s return std::unique_ptr(new VulkanShader(stage, mod)); } -std::unique_ptr VulkanDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, +std::unique_ptr VulkanDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source, const char* entry_point, DynamicHeapArray* out_binary) { @@ -115,7 +115,7 @@ VulkanPipeline::~VulkanPipeline() VulkanDevice::GetInstance().DeferPipelineDestruction(m_pipeline); } -void VulkanPipeline::SetDebugName(const std::string_view& name) +void VulkanPipeline::SetDebugName(std::string_view name) { Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_pipeline, name); } diff --git a/src/util/vulkan_pipeline.h b/src/util/vulkan_pipeline.h index db355a714..d77b5637f 100644 --- a/src/util/vulkan_pipeline.h +++ b/src/util/vulkan_pipeline.h @@ -15,7 +15,7 @@ public: ALWAYS_INLINE VkShaderModule GetModule() const { return m_module; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: VulkanShader(GPUShaderStage stage, VkShaderModule mod); @@ -34,7 +34,7 @@ public: ALWAYS_INLINE Layout GetLayout() const { return m_layout; } ALWAYS_INLINE u8 GetVerticesPerPrimitive() const { return m_vertices_per_primitive; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: VulkanPipeline(VkPipeline pipeline, Layout layout, u8 vertices_per_primitive, RenderPassFlag render_pass_flags); diff --git a/src/util/vulkan_texture.cpp b/src/util/vulkan_texture.cpp index d9aa6f6f1..9646ff972 100644 --- a/src/util/vulkan_texture.cpp +++ b/src/util/vulkan_texture.cpp @@ -474,7 +474,7 @@ void VulkanTexture::OverrideImageLayout(Layout new_layout) m_layout = new_layout; } -void VulkanTexture::SetDebugName(const std::string_view& name) +void VulkanTexture::SetDebugName(std::string_view name) { VulkanDevice& dev = VulkanDevice::GetInstance(); Vulkan::SetObjectName(dev.GetVulkanDevice(), m_image, name); @@ -751,7 +751,7 @@ VulkanSampler::~VulkanSampler() // Cleaned up by main class. } -void VulkanSampler::SetDebugName(const std::string_view& name) +void VulkanSampler::SetDebugName(std::string_view name) { Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_sampler, name); } @@ -915,7 +915,7 @@ void VulkanTextureBuffer::Unmap(u32 used_elements) m_buffer.CommitMemory(size); } -void VulkanTextureBuffer::SetDebugName(const std::string_view& name) +void VulkanTextureBuffer::SetDebugName(std::string_view name) { VulkanDevice& dev = VulkanDevice::GetInstance(); Vulkan::SetObjectName(dev.GetVulkanDevice(), m_buffer.GetBuffer(), name); diff --git a/src/util/vulkan_texture.h b/src/util/vulkan_texture.h index 479b0a1c8..9679d88ba 100644 --- a/src/util/vulkan_texture.h +++ b/src/util/vulkan_texture.h @@ -55,7 +55,7 @@ public: void Unmap() override; void MakeReadyForSampling() override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; void TransitionToLayout(Layout layout); void CommitClear(); @@ -119,7 +119,7 @@ public: ALWAYS_INLINE VkSampler GetSampler() const { return m_sampler; } - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: VulkanSampler(VkSampler sampler); @@ -145,7 +145,7 @@ public: void* Map(u32 required_elements) override; void Unmap(u32 used_elements) override; - void SetDebugName(const std::string_view& name) override; + void SetDebugName(std::string_view name) override; private: VulkanStreamBuffer m_buffer; diff --git a/src/util/win32_raw_input_source.cpp b/src/util/win32_raw_input_source.cpp index ade9f59b7..c7bea9c04 100644 --- a/src/util/win32_raw_input_source.cpp +++ b/src/util/win32_raw_input_source.cpp @@ -83,8 +83,7 @@ void Win32RawInputSource::UpdateMotorState(InputBindingKey large_key, InputBindi { } -std::optional Win32RawInputSource::ParseKeyString(const std::string_view& device, - const std::string_view& binding) +std::optional Win32RawInputSource::ParseKeyString(std::string_view device, std::string_view binding) { return std::nullopt; } @@ -104,7 +103,7 @@ std::vector Win32RawInputSource::EnumerateMotors() return {}; } -bool Win32RawInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) +bool Win32RawInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) { return {}; } diff --git a/src/util/win32_raw_input_source.h b/src/util/win32_raw_input_source.h index 4ed8833c4..af7400e4e 100644 --- a/src/util/win32_raw_input_source.h +++ b/src/util/win32_raw_input_source.h @@ -25,13 +25,12 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(std::string_view device, 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(std::string_view device, std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override; diff --git a/src/util/xinput_source.cpp b/src/util/xinput_source.cpp index dec3fc9e5..ff88ab870 100644 --- a/src/util/xinput_source.cpp +++ b/src/util/xinput_source.cpp @@ -250,8 +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(std::string_view device, std::string_view binding) { if (!device.starts_with("XInput-") || binding.empty()) return std::nullopt; @@ -351,7 +350,7 @@ TinyString XInputSource::ConvertKeyToIcon(InputBindingKey key) if (key.data < std::size(s_axis_icons) && key.modifier != InputModifier::FullAxis) { ret.format("XInput-{} {}", static_cast(key.source_index), - s_axis_icons[key.data][key.modifier == InputModifier::None]); + s_axis_icons[key.data][key.modifier == InputModifier::None]); } } else if (key.source_subtype == InputSubclass::ControllerButton) @@ -384,7 +383,7 @@ std::vector XInputSource::EnumerateMotors() return ret; } -bool XInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) +bool XInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) { if (!device.starts_with("XInput-")) return false; diff --git a/src/util/xinput_source.h b/src/util/xinput_source.h index f52ca32c8..c51d907fb 100644 --- a/src/util/xinput_source.h +++ b/src/util/xinput_source.h @@ -43,13 +43,12 @@ public: void PollEvents() override; std::vector> EnumerateDevices() override; std::vector EnumerateMotors() override; - bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; + bool GetGenericBindingMapping(std::string_view device, 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(std::string_view device, std::string_view binding) override; TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;