Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass strings by const reference and use find_last_not_of #779

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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