From 3d422b11c0e984c6e3453cd6b2fa4006f51fe69a Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Thu, 14 Dec 2023 14:23:31 +0300 Subject: [PATCH] [GPU Common Vulkan/UI/Windows Debugger] Added const reference for function params --- GPU/Common/TextureShaderCommon.cpp | 2 +- GPU/Common/TextureShaderCommon.h | 2 +- GPU/Vulkan/PipelineManagerVulkan.cpp | 4 ++-- GPU/Vulkan/PipelineManagerVulkan.h | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 4 ++-- GPU/Vulkan/TextureCacheVulkan.h | 4 ++-- UI/ControlMappingScreen.cpp | 6 +++--- UI/ControlMappingScreen.h | 2 +- UI/MemStickScreen.cpp | 4 ++-- UI/MemStickScreen.h | 2 +- UI/SavedataScreen.cpp | 2 +- UI/Store.cpp | 10 +++++----- UI/Store.h | 4 ++-- Windows/Debugger/CtrlDisAsmView.cpp | 2 +- Windows/Debugger/CtrlDisAsmView.h | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index 2e8b597802..a4a979126d 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -241,7 +241,7 @@ std::vector TextureShaderCache::DebugGetShaderIDs(DebugShaderType t return ids; } -std::string TextureShaderCache::DebugGetShaderString(std::string idstr, DebugShaderType type, DebugShaderStringType stringType) { +std::string TextureShaderCache::DebugGetShaderString(const std::string &idstr, DebugShaderType type, DebugShaderStringType stringType) { uint32_t id = 0; sscanf(idstr.c_str(), "%08x", &id); auto iter = depalCache_.find(id); diff --git a/GPU/Common/TextureShaderCommon.h b/GPU/Common/TextureShaderCommon.h index 8aa881fdc8..b029c739a6 100644 --- a/GPU/Common/TextureShaderCommon.h +++ b/GPU/Common/TextureShaderCommon.h @@ -54,7 +54,7 @@ public: void Clear(); void Decimate(); std::vector DebugGetShaderIDs(DebugShaderType type); - std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType); + std::string DebugGetShaderString(const std::string &id, DebugShaderType type, DebugShaderStringType stringType); void DeviceLost(); void DeviceRestore(Draw::DrawContext *draw); diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 5325027bc8..6bbced6a87 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -166,7 +166,7 @@ static bool UsesBlendConstant(int factor) { } } -static std::string CutFromMain(std::string str) { +static std::string CutFromMain(const std::string &str) { std::vector lines; SplitString(str, '\n', lines); @@ -495,7 +495,7 @@ static const char *const blendFactors[19] = { "INV_SRC1_A", }; -std::string PipelineManagerVulkan::DebugGetObjectString(std::string id, DebugShaderType type, DebugShaderStringType stringType, ShaderManagerVulkan *shaderManager) { +std::string PipelineManagerVulkan::DebugGetObjectString(const std::string &id, DebugShaderType type, DebugShaderStringType stringType, ShaderManagerVulkan *shaderManager) { if (type != SHADER_TYPE_PIPELINE) return "N/A"; diff --git a/GPU/Vulkan/PipelineManagerVulkan.h b/GPU/Vulkan/PipelineManagerVulkan.h index cd9311af50..9a95259b33 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.h +++ b/GPU/Vulkan/PipelineManagerVulkan.h @@ -95,7 +95,7 @@ public: void InvalidateMSAAPipelines(); - std::string DebugGetObjectString(std::string id, DebugShaderType type, DebugShaderStringType stringType, ShaderManagerVulkan *shaderManager); + std::string DebugGetObjectString(const std::string &id, DebugShaderType type, DebugShaderStringType stringType, ShaderManagerVulkan *shaderManager); std::vector DebugGetObjectIDs(DebugShaderType type) const; // Saves data for faster creation next time. diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 7525f80fcf..f6550eb3f0 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -159,7 +159,7 @@ VkSampler SamplerCache::GetOrCreateSampler(const SamplerCacheKey &key) { return sampler; } -std::string SamplerCache::DebugGetSamplerString(std::string id, DebugShaderStringType stringType) { +std::string SamplerCache::DebugGetSamplerString(const std::string &id, DebugShaderStringType stringType) { SamplerCacheKey key; key.FromString(id); return StringFromFormat("%s/%s mag:%s min:%s mip:%s maxLod:%f minLod:%f bias:%f", @@ -852,7 +852,7 @@ std::vector TextureCacheVulkan::DebugGetSamplerIDs() const { return samplerCache_.DebugGetSamplerIDs(); } -std::string TextureCacheVulkan::DebugGetSamplerString(std::string id, DebugShaderStringType stringType) { +std::string TextureCacheVulkan::DebugGetSamplerString(const std::string &id, DebugShaderStringType stringType) { return samplerCache_.DebugGetSamplerString(id, stringType); } diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 3dbf725d90..806ef13d59 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -44,7 +44,7 @@ public: void DeviceRestore(VulkanContext *vulkan); std::vector DebugGetSamplerIDs() const; - std::string DebugGetSamplerString(std::string id, DebugShaderStringType stringType); + std::string DebugGetSamplerString(const std::string &id, DebugShaderStringType stringType); private: VulkanContext *vulkan_; @@ -81,7 +81,7 @@ public: VulkanDeviceAllocator *GetAllocator() { return allocator_; } std::vector DebugGetSamplerIDs() const; - std::string DebugGetSamplerString(std::string id, DebugShaderStringType stringType); + std::string DebugGetSamplerString(const std::string &id, DebugShaderStringType stringType); protected: void BindTexture(TexCacheEntry *entry) override; diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 6181a9f429..e0beb50be6 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -69,7 +69,7 @@ private: UI::EventReturn OnReplace(UI::EventParams ¶ms); UI::EventReturn OnReplaceAll(UI::EventParams ¶ms); - void MappedCallback(MultiInputMapping key); + void MappedCallback(const MultiInputMapping &key); enum Action { NONE, @@ -163,7 +163,7 @@ void SingleControlMapper::Refresh() { } } -void SingleControlMapper::MappedCallback(MultiInputMapping kdf) { +void SingleControlMapper::MappedCallback(const MultiInputMapping &kdf) { if (kdf.empty()) { // Don't want to try to add this. return; @@ -1192,7 +1192,7 @@ UI::EventReturn VisualMappingScreen::OnBindAll(UI::EventParams &e) { return UI::EVENT_DONE; } -void VisualMappingScreen::HandleKeyMapping(MultiInputMapping key) { +void VisualMappingScreen::HandleKeyMapping(const KeyMap::MultiInputMapping &key) { KeyMap::SetInputMapping(nextKey_, key, replace_); KeyMap::UpdateNativeMenuKeys(); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index d096fdec53..c31218a47a 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -197,7 +197,7 @@ protected: private: UI::EventReturn OnMapButton(UI::EventParams &e); UI::EventReturn OnBindAll(UI::EventParams &e); - void HandleKeyMapping(KeyMap::MultiInputMapping key); + void HandleKeyMapping(const KeyMap::MultiInputMapping &key); void MapNext(bool successive); MockPSP *psp_ = nullptr; diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index 3e39811dff..9050368d84 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -50,7 +50,7 @@ #include "UI/MiscScreens.h" #include "UI/OnScreenDisplay.h" -static bool FolderSeemsToBeUsed(Path newMemstickFolder) { +static bool FolderSeemsToBeUsed(const Path &newMemstickFolder) { // Inspect the potential new folder, quickly. if (File::Exists(newMemstickFolder / "PSP/SAVEDATA") || File::Exists(newMemstickFolder / "SAVEDATA")) { // Does seem likely. We could add more criteria like checking for actual savegames or something. @@ -514,7 +514,7 @@ struct FileSuffix { u64 fileSize; }; -static bool ListFileSuffixesRecursively(const Path &root, Path folder, std::vector &dirSuffixes, std::vector &fileSuffixes) { +static bool ListFileSuffixesRecursively(const Path &root, const Path &folder, std::vector &dirSuffixes, std::vector &fileSuffixes) { std::vector files; if (!File::GetFilesInDir(folder, &files)) { return false; diff --git a/UI/MemStickScreen.h b/UI/MemStickScreen.h index cf0eecbc1b..bf30f6373c 100644 --- a/UI/MemStickScreen.h +++ b/UI/MemStickScreen.h @@ -93,7 +93,7 @@ private: class ProgressReporter { public: - void Set(std::string value) { + void Set(const std::string &value) { std::lock_guard guard(mutex_); progress_ = value; } diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index de24b953b0..e04e9e8b16 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -266,7 +266,7 @@ UI::EventReturn SavedataPopupScreen::OnDeleteButtonClick(UI::EventParams &e) { return UI::EVENT_DONE; } -static std::string CleanSaveString(std::string str) { +static std::string CleanSaveString(const std::string &str) { std::string s = ReplaceAll(str, "&", "&&"); s = ReplaceAll(s, "\n", " "); s = ReplaceAll(s, "\r", " "); diff --git a/UI/Store.cpp b/UI/Store.cpp index baacc3de9a..7381ef5bbf 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -43,7 +43,7 @@ static std::string StoreBaseUrl() { } // baseUrl is assumed to have a trailing slash, and not contain any subdirectories. -std::string ResolveUrl(std::string baseUrl, std::string url) { +std::string ResolveUrl(const std::string &baseUrl, const std::string &url) { if (url.empty()) { return baseUrl; } else if (url[0] == '/') { @@ -91,7 +91,7 @@ public: void Draw(UIContext &dc) override; std::string DescribeText() const override { return ""; } - void SetFilename(std::string filename); + void SetFilename(const std::string &filename); void SetColor(uint32_t color) { color_ = color; } void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; } void SetCanBeFocused(bool can) { canFocus_ = can; } @@ -150,7 +150,7 @@ void HttpImageFileView::GetContentDimensions(const UIContext &dc, float &w, floa } } -void HttpImageFileView::SetFilename(std::string filename) { +void HttpImageFileView::SetFilename(const std::string &filename) { if (!useIconCache_ && path_ != filename) { textureFailed_ = false; path_ = filename; @@ -454,7 +454,7 @@ void StoreScreen::update() { } } -void StoreScreen::ParseListing(std::string json) { +void StoreScreen::ParseListing(const std::string &json) { using namespace json; JsonReader reader(json.c_str(), json.size()); if (!reader.ok() || !reader.root()) { @@ -585,7 +585,7 @@ UI::EventReturn StoreScreen::OnRetry(UI::EventParams &e) { return UI::EVENT_DONE; } -std::string StoreScreen::GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback) const { +std::string StoreScreen::GetTranslatedString(const json::JsonGet json, const std::string &key, const char *fallback) const { json::JsonGet dict = json.getDict("en_US"); if (dict && json.hasChild(lang_.c_str(), JSON_OBJECT)) { if (json.getDict(lang_.c_str()).hasChild(key.c_str(), JSON_STRING)) { diff --git a/UI/Store.h b/UI/Store.h index 64d62e16e8..1782037b9b 100644 --- a/UI/Store.h +++ b/UI/Store.h @@ -72,10 +72,10 @@ protected: UI::EventReturn OnGameLaunch(UI::EventParams &e); private: - void ParseListing(std::string json); + void ParseListing(const std::string &json); ProductItemView *GetSelectedItem(); - std::string GetTranslatedString(const json::JsonGet json, std::string key, const char *fallback = nullptr) const; + std::string GetTranslatedString(const json::JsonGet json, const std::string &key, const char *fallback = nullptr) const; std::shared_ptr listing_; std::shared_ptr image_; diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 946a131a1c..8d9809fd8f 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -277,7 +277,7 @@ std::string trimString(std::string input) return input; } -void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText) +void CtrlDisAsmView::assembleOpcode(u32 address, const std::string &defaultText) { auto memLock = Memory::Lock(); if (Core_IsStepping() == false) { diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index eca66393dc..d58b999360 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -67,7 +67,7 @@ class CtrlDisAsmView ADDRESSES, }; - void assembleOpcode(u32 address, std::string defaultText); + void assembleOpcode(u32 address, const std::string &defaultText); std::string disassembleRange(u32 start, u32 size); void disassembleToFile(); void search(bool continueSearch);