From 7ae8907674db204bb8cc12138d900eec40751e8e Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Thu, 17 Feb 2022 07:09:10 +1100 Subject: [PATCH] Remove unnecessary static std::string variables (PR #1039) --- source/Registry.cpp | 23 ++++++----------------- source/Registry.h | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/source/Registry.cpp b/source/Registry.cpp index baeda65e..a4f1ec25 100644 --- a/source/Registry.cpp +++ b/source/Registry.cpp @@ -153,27 +153,16 @@ void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value) { } //=========================================================================== -static std::string& RegGetSlotSection(UINT slot) +static inline std::string RegGetSlotSection(UINT slot) { - static std::string section; - if (slot == SLOT_AUX) - { - section = REG_CONFIG_SLOT_AUX; - } - else - { - section = REG_CONFIG_SLOT; - section += (char)('0' + slot); - } - return section; + return (slot == SLOT_AUX) + ? std::string(REG_CONFIG_SLOT_AUX) + : (std::string(REG_CONFIG_SLOT) + (char)('0' + slot)); } -std::string& RegGetConfigSlotSection(UINT slot) +std::string RegGetConfigSlotSection(UINT slot) { - static std::string section; - section = REG_CONFIG "\\"; - section += RegGetSlotSection(slot); - return section; + return std::string(REG_CONFIG "\\") + RegGetSlotSection(slot); } void RegDeleteConfigSlotSection(UINT slot) diff --git a/source/Registry.h b/source/Registry.h index 9d3da777..0f014c12 100644 --- a/source/Registry.h +++ b/source/Registry.h @@ -12,6 +12,6 @@ BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD* value, DWO void RegSaveString (LPCTSTR section, LPCTSTR key, BOOL peruser, const std::string & buffer); void RegSaveValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD value); -std::string& RegGetConfigSlotSection(UINT slot); +std::string RegGetConfigSlotSection(UINT slot); void RegDeleteConfigSlotSection(UINT slot); void RegSetConfigSlotNewCardType(UINT slot, enum SS_CARDTYPE type);