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
main continuous
soyer 1 week ago committed by GitHub
parent ffb6449258
commit 0f7f8f45e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      src/minidexed.cpp
  2. 4
      src/minidexed.h
  3. 12
      src/performanceconfig.cpp
  4. 2
      src/performanceconfig.h

@ -1968,9 +1968,9 @@ std::string CMiniDexed::GetNewPerformanceDefaultName(void)
return m_PerformanceConfig.GetNewPerformanceDefaultName(); return m_PerformanceConfig.GetNewPerformanceDefaultName();
} }
void CMiniDexed::SetNewPerformanceName(std::string nName) void CMiniDexed::SetNewPerformanceName(const std::string &Name)
{ {
m_PerformanceConfig.SetNewPerformanceName(nName); m_PerformanceConfig.SetNewPerformanceName(Name);
} }
bool CMiniDexed::IsValidPerformance(unsigned nID) bool CMiniDexed::IsValidPerformance(unsigned nID)
@ -1983,7 +1983,7 @@ bool CMiniDexed::IsValidPerformanceBank(unsigned nBankID)
return m_PerformanceConfig.IsValidPerformanceBank(nBankID); return m_PerformanceConfig.IsValidPerformanceBank(nBankID);
} }
void CMiniDexed::SetVoiceName (std::string VoiceName, unsigned nTG) void CMiniDexed::SetVoiceName (const std::string &VoiceName, unsigned nTG)
{ {
assert (nTG < CConfig::AllToneGenerators); assert (nTG < CConfig::AllToneGenerators);
if (nTG >= m_nToneGenerators) return; // Not an active TG if (nTG >= m_nToneGenerators) return; // Not an active TG

@ -164,8 +164,8 @@ public:
int GetParameter (TParameter Parameter); int GetParameter (TParameter Parameter);
std::string GetNewPerformanceDefaultName(void); std::string GetNewPerformanceDefaultName(void);
void SetNewPerformanceName(std::string nName); void SetNewPerformanceName(const std::string &Name);
void SetVoiceName (std::string VoiceName, unsigned nTG); void SetVoiceName (const std::string &VoiceName, unsigned nTG);
bool DeletePerformance(unsigned nID); bool DeletePerformance(unsigned nID);
bool DoDeletePerformance(void); bool DoDeletePerformance(void);

@ -1095,17 +1095,9 @@ std::string CPerformanceConfig::GetNewPerformanceDefaultName(void)
return "Perf" + nIndex; return "Perf" + nIndex;
} }
void CPerformanceConfig::SetNewPerformanceName(std::string nName) void CPerformanceConfig::SetNewPerformanceName(const std::string &Name)
{ {
int i = nName.length(); NewPerformanceName = Name.substr(0, Name.find_last_not_of(' ') + 1);
do
{
--i;
}
while (i>=0 && nName[i] == 32);
nName=nName.substr(0,i+1) ;
NewPerformanceName = nName;
} }
bool CPerformanceConfig::DeletePerformance(unsigned nID) bool CPerformanceConfig::DeletePerformance(unsigned nID)

@ -137,7 +137,7 @@ public:
bool CreateNewPerformanceFile(void); bool CreateNewPerformanceFile(void);
bool GetInternalFolderOk(); bool GetInternalFolderOk();
std::string GetNewPerformanceDefaultName(void); std::string GetNewPerformanceDefaultName(void);
void SetNewPerformanceName(std::string nName); void SetNewPerformanceName(const std::string &Name);
bool DeletePerformance(unsigned nID); bool DeletePerformance(unsigned nID);
bool CheckFreePerformanceSlot(void); bool CheckFreePerformanceSlot(void);
std::string AddPerformanceBankDirName(unsigned nBankID); std::string AddPerformanceBankDirName(unsigned nBankID);

Loading…
Cancel
Save