Skip to content

Commit 0f7f8f4

Browse files
authored
pass strings by const reference and use find_last_not_of (#779)
* pass std::strings by const reference * use std::string::find_last_not_of
1 parent ffb6449 commit 0f7f8f4

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

src/minidexed.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1968,9 +1968,9 @@ std::string CMiniDexed::GetNewPerformanceDefaultName(void)
19681968
return m_PerformanceConfig.GetNewPerformanceDefaultName();
19691969
}
19701970

1971-
void CMiniDexed::SetNewPerformanceName(std::string nName)
1971+
void CMiniDexed::SetNewPerformanceName(const std::string &Name)
19721972
{
1973-
m_PerformanceConfig.SetNewPerformanceName(nName);
1973+
m_PerformanceConfig.SetNewPerformanceName(Name);
19741974
}
19751975

19761976
bool CMiniDexed::IsValidPerformance(unsigned nID)
@@ -1983,7 +1983,7 @@ bool CMiniDexed::IsValidPerformanceBank(unsigned nBankID)
19831983
return m_PerformanceConfig.IsValidPerformanceBank(nBankID);
19841984
}
19851985

1986-
void CMiniDexed::SetVoiceName (std::string VoiceName, unsigned nTG)
1986+
void CMiniDexed::SetVoiceName (const std::string &VoiceName, unsigned nTG)
19871987
{
19881988
assert (nTG < CConfig::AllToneGenerators);
19891989
if (nTG >= m_nToneGenerators) return; // Not an active TG

src/minidexed.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ class CMiniDexed
164164
int GetParameter (TParameter Parameter);
165165

166166
std::string GetNewPerformanceDefaultName(void);
167-
void SetNewPerformanceName(std::string nName);
168-
void SetVoiceName (std::string VoiceName, unsigned nTG);
167+
void SetNewPerformanceName(const std::string &Name);
168+
void SetVoiceName (const std::string &VoiceName, unsigned nTG);
169169
bool DeletePerformance(unsigned nID);
170170
bool DoDeletePerformance(void);
171171

src/performanceconfig.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -1095,17 +1095,9 @@ std::string CPerformanceConfig::GetNewPerformanceDefaultName(void)
10951095
return "Perf" + nIndex;
10961096
}
10971097

1098-
void CPerformanceConfig::SetNewPerformanceName(std::string nName)
1098+
void CPerformanceConfig::SetNewPerformanceName(const std::string &Name)
10991099
{
1100-
int i = nName.length();
1101-
do
1102-
{
1103-
--i;
1104-
}
1105-
while (i>=0 && nName[i] == 32);
1106-
nName=nName.substr(0,i+1) ;
1107-
1108-
NewPerformanceName = nName;
1100+
NewPerformanceName = Name.substr(0, Name.find_last_not_of(' ') + 1);
11091101
}
11101102

11111103
bool CPerformanceConfig::DeletePerformance(unsigned nID)

src/performanceconfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CPerformanceConfig // Performance configuration
137137
bool CreateNewPerformanceFile(void);
138138
bool GetInternalFolderOk();
139139
std::string GetNewPerformanceDefaultName(void);
140-
void SetNewPerformanceName(std::string nName);
140+
void SetNewPerformanceName(const std::string &Name);
141141
bool DeletePerformance(unsigned nID);
142142
bool CheckFreePerformanceSlot(void);
143143
std::string AddPerformanceBankDirName(unsigned nBankID);

0 commit comments

Comments
 (0)