From 132142d5aeed43a8dfc65d7e671577bd0c5d7722 Mon Sep 17 00:00:00 2001 From: darkf <> Date: Mon, 6 Apr 2020 00:17:57 -0700 Subject: [PATCH] Use const string references for profile methods --- src/common/input/InputWindow.cpp | 12 ++++++------ src/common/input/InputWindow.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/common/input/InputWindow.cpp b/src/common/input/InputWindow.cpp index de1b5b015..41b3de712 100644 --- a/src/common/input/InputWindow.cpp +++ b/src/common/input/InputWindow.cpp @@ -271,7 +271,7 @@ int InputWindow::EnableDefaultButton() } } -InputWindow::ProfileIt InputWindow::FindProfile(std::string& name) +InputWindow::ProfileIt InputWindow::FindProfile(const std::string& name) { auto it = std::find_if(g_Settings->m_input_profiles[m_dev_type].begin(), g_Settings->m_input_profiles[m_dev_type].end(), [&name](const auto& profile) { @@ -280,7 +280,7 @@ InputWindow::ProfileIt InputWindow::FindProfile(std::string& name) return it; } -void InputWindow::UpdateProfile(std::string& name, int command) +void InputWindow::UpdateProfile(const std::string& name, int command) { switch (command) { @@ -314,7 +314,7 @@ void InputWindow::UpdateProfile(std::string& name, int command) } } -void InputWindow::LoadProfile(std::string& name) +void InputWindow::LoadProfile(const std::string& name) { ProfileIt profile = FindProfile(name); if (profile == g_Settings->m_input_profiles[m_dev_type].end()) { @@ -339,7 +339,7 @@ void InputWindow::LoadProfile(std::string& name) m_bHasChanges = false; } -bool InputWindow::SaveProfile(std::string& name) +bool InputWindow::SaveProfile(const std::string& name) { if (name == std::string()) { MessageBox(m_hwnd_window, "Cannot save. Profile name must not be empty", "Cxbx-Reloaded", MB_OK | MB_ICONSTOP | MB_APPLMODAL); @@ -368,7 +368,7 @@ bool InputWindow::SaveProfile(std::string& name) return true; } -void InputWindow::DeleteProfile(std::string& name) +void InputWindow::DeleteProfile(const std::string& name) { ProfileIt profile = FindProfile(name); if (profile == g_Settings->m_input_profiles[m_dev_type].end()) { @@ -390,7 +390,7 @@ void InputWindow::DeleteProfile(std::string& name) g_Settings->m_input_profiles[m_dev_type].erase(profile); } -void InputWindow::OverwriteProfile(std::string& name) +void InputWindow::OverwriteProfile(const std::string& name) { ProfileIt profile = FindProfile(name); if (profile == g_Settings->m_input_profiles[m_dev_type].end()) { diff --git a/src/common/input/InputWindow.h b/src/common/input/InputWindow.h index 1315b5b24..c806cb2fa 100644 --- a/src/common/input/InputWindow.h +++ b/src/common/input/InputWindow.h @@ -56,7 +56,7 @@ public: void BindButton(int ControlID); void BindDefault(); void ClearBindings(); - void UpdateProfile(std::string& name, int command); + void UpdateProfile(const std::string& name, int command); void UpdateRumble(int command); void UpdateCurrentDevice(); bool IsProfileSaved(); @@ -66,11 +66,11 @@ private: typedef std::vector::iterator ProfileIt; InputDevice::Input* DetectInput(InputDevice* const Device, int ms); void DetectOutput(int ms); - ProfileIt FindProfile(std::string& name); - void LoadProfile(std::string& name); - bool SaveProfile(std::string& name); - void DeleteProfile(std::string& name); - void OverwriteProfile(std::string& name); + ProfileIt FindProfile(const std::string& name); + void LoadProfile(const std::string& name); + bool SaveProfile(const std::string& name); + void DeleteProfile(const std::string& name); + void OverwriteProfile(const std::string& name); void LoadDefaultProfile(); int EnableDefaultButton();