Skip to content

Commit

Permalink
pass strings by const reference and use find_last_not_of (#779)
Browse files Browse the repository at this point in the history
* pass std::strings by const reference

* use std::string::find_last_not_of
  • Loading branch information
soyersoyer authored Jan 2, 2025
1 parent ffb6449 commit 0f7f8f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1968,9 +1968,9 @@ std::string CMiniDexed::GetNewPerformanceDefaultName(void)
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)
Expand All @@ -1983,7 +1983,7 @@ bool CMiniDexed::IsValidPerformanceBank(unsigned 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);
if (nTG >= m_nToneGenerators) return; // Not an active TG
Expand Down
4 changes: 2 additions & 2 deletions src/minidexed.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class CMiniDexed
int GetParameter (TParameter Parameter);

std::string GetNewPerformanceDefaultName(void);
void SetNewPerformanceName(std::string nName);
void SetVoiceName (std::string VoiceName, unsigned nTG);
void SetNewPerformanceName(const std::string &Name);
void SetVoiceName (const std::string &VoiceName, unsigned nTG);
bool DeletePerformance(unsigned nID);
bool DoDeletePerformance(void);

Expand Down
12 changes: 2 additions & 10 deletions src/performanceconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,17 +1095,9 @@ std::string CPerformanceConfig::GetNewPerformanceDefaultName(void)
return "Perf" + nIndex;
}

void CPerformanceConfig::SetNewPerformanceName(std::string nName)
void CPerformanceConfig::SetNewPerformanceName(const std::string &Name)
{
int i = nName.length();
do
{
--i;
}
while (i>=0 && nName[i] == 32);
nName=nName.substr(0,i+1) ;

NewPerformanceName = nName;
NewPerformanceName = Name.substr(0, Name.find_last_not_of(' ') + 1);
}

bool CPerformanceConfig::DeletePerformance(unsigned nID)
Expand Down
2 changes: 1 addition & 1 deletion src/performanceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class CPerformanceConfig // Performance configuration
bool CreateNewPerformanceFile(void);
bool GetInternalFolderOk();
std::string GetNewPerformanceDefaultName(void);
void SetNewPerformanceName(std::string nName);
void SetNewPerformanceName(const std::string &Name);
bool DeletePerformance(unsigned nID);
bool CheckFreePerformanceSlot(void);
std::string AddPerformanceBankDirName(unsigned nBankID);
Expand Down

0 comments on commit 0f7f8f4

Please sign in to comment.