mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-06 07:29:07 +02:00
Sweep unnecessary wxString copies: commands
This commit is contained in:
parent
99f161c36c
commit
923a6ce4af
@ -39,12 +39,12 @@ void DecoratedCommand::Progress(double completed)
|
||||
mCommand->Progress(completed);
|
||||
}
|
||||
|
||||
void DecoratedCommand::Status(wxString message)
|
||||
void DecoratedCommand::Status(const wxString &message)
|
||||
{
|
||||
mCommand->Status(message);
|
||||
}
|
||||
|
||||
void DecoratedCommand::Error(wxString message)
|
||||
void DecoratedCommand::Error(const wxString &message)
|
||||
{
|
||||
mCommand->Error(message);
|
||||
}
|
||||
@ -162,12 +162,12 @@ void CommandImplementation::Progress(double completed)
|
||||
mOutput->Progress(completed);
|
||||
}
|
||||
|
||||
void CommandImplementation::Status(wxString status)
|
||||
void CommandImplementation::Status(const wxString &status)
|
||||
{
|
||||
mOutput->Status(status);
|
||||
}
|
||||
|
||||
void CommandImplementation::Error(wxString message)
|
||||
void CommandImplementation::Error(const wxString &message)
|
||||
{
|
||||
mOutput->Error(message);
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ class Command
|
||||
{
|
||||
public:
|
||||
virtual void Progress(double completed) = 0;
|
||||
virtual void Status(wxString message) = 0;
|
||||
virtual void Error(wxString message) = 0;
|
||||
virtual void Status(const wxString &message) = 0;
|
||||
virtual void Error(const wxString &message) = 0;
|
||||
virtual ~Command() { }
|
||||
virtual wxString GetName() = 0;
|
||||
virtual CommandSignature &GetSignature() = 0;
|
||||
@ -77,8 +77,8 @@ protected:
|
||||
Command *mCommand;
|
||||
public:
|
||||
virtual void Progress(double completed);
|
||||
virtual void Status(wxString message);
|
||||
virtual void Error(wxString message);
|
||||
virtual void Status(const wxString &message) override;
|
||||
virtual void Error(const wxString &message) override;
|
||||
|
||||
DecoratedCommand(Command *cmd)
|
||||
: mCommand(cmd)
|
||||
@ -130,8 +130,8 @@ protected:
|
||||
public:
|
||||
// Convenience methods for passing messages to the output target
|
||||
void Progress(double completed);
|
||||
void Status(wxString status);
|
||||
void Error(wxString message);
|
||||
void Status(const wxString &status) override;
|
||||
void Error(const wxString &message) override;
|
||||
|
||||
/// Constructor should not be called directly; only by a factory which
|
||||
/// ensures name and params are set appropriately for the command.
|
||||
|
@ -87,7 +87,7 @@ void CommandBuilder::Success(Command *cmd)
|
||||
}
|
||||
|
||||
void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
wxString cmdParams)
|
||||
const wxString &cmdParamsArg)
|
||||
{
|
||||
// Stage 1: create a Command object of the right type
|
||||
|
||||
@ -106,7 +106,7 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
wxASSERT(type != NULL);
|
||||
mCommand = type->Create(output);
|
||||
mCommand->SetParameter(wxT("CommandName"), cmdName);
|
||||
mCommand->SetParameter(wxT("ParamString"), cmdParams);
|
||||
mCommand->SetParameter(wxT("ParamString"), cmdParamsArg);
|
||||
Success(new ApplyAndSendResponse(mCommand));
|
||||
return;
|
||||
}
|
||||
@ -117,7 +117,7 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
// Stage 2: set the parameters
|
||||
|
||||
ShuttleCli shuttle;
|
||||
shuttle.mParams = cmdParams;
|
||||
shuttle.mParams = cmdParamsArg;
|
||||
shuttle.mbStoreInClient = true;
|
||||
|
||||
ParamValueMap::const_iterator iter;
|
||||
@ -138,6 +138,8 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
|
||||
// Check for unrecognised parameters
|
||||
|
||||
wxString cmdParams(cmdParamsArg);
|
||||
|
||||
while (cmdParams != wxEmptyString)
|
||||
{
|
||||
cmdParams.Trim(true);
|
||||
@ -166,8 +168,10 @@ void CommandBuilder::BuildCommand(const wxString &cmdName,
|
||||
Success(new ApplyAndSendResponse(mCommand));
|
||||
}
|
||||
|
||||
void CommandBuilder::BuildCommand(wxString cmdString)
|
||||
void CommandBuilder::BuildCommand(const wxString &cmdStringArg)
|
||||
{
|
||||
wxString cmdString(cmdStringArg);
|
||||
|
||||
// Find the command name terminator... If there is more than one word and
|
||||
// no terminator, the command is badly formed
|
||||
cmdString.Trim(true); cmdString.Trim(false);
|
||||
|
@ -31,8 +31,8 @@ class CommandBuilder
|
||||
|
||||
void Failure(const wxString &msg = wxEmptyString);
|
||||
void Success(Command *cmd);
|
||||
void BuildCommand(const wxString &cmdName, wxString cmdParams);
|
||||
void BuildCommand(wxString cmdString);
|
||||
void BuildCommand(const wxString &cmdName, const wxString &cmdParams);
|
||||
void BuildCommand(const wxString &cmdString);
|
||||
public:
|
||||
CommandBuilder(const wxString &cmdString);
|
||||
CommandBuilder(const wxString &cmdName,
|
||||
|
@ -957,7 +957,7 @@ void CommandManager::Enable(CommandListEntry *entry, bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::Enable(wxString name, bool enabled)
|
||||
void CommandManager::Enable(const wxString &name, bool enabled)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry || !entry->menu) {
|
||||
@ -997,7 +997,7 @@ bool CommandManager::GetEnabled(const wxString &name)
|
||||
return entry->enabled;
|
||||
}
|
||||
|
||||
void CommandManager::Check(wxString name, bool checked)
|
||||
void CommandManager::Check(const wxString &name, bool checked)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry || !entry->menu) {
|
||||
@ -1008,7 +1008,7 @@ void CommandManager::Check(wxString name, bool checked)
|
||||
}
|
||||
|
||||
///Changes the label text of a menu item
|
||||
void CommandManager::Modify(wxString name, wxString newLabel)
|
||||
void CommandManager::Modify(const wxString &name, const wxString &newLabel)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (entry && entry->menu) {
|
||||
@ -1017,7 +1017,7 @@ void CommandManager::Modify(wxString name, wxString newLabel)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::SetKeyFromName(wxString name, wxString key)
|
||||
void CommandManager::SetKeyFromName(const wxString &name, const wxString &key)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (entry) {
|
||||
@ -1025,7 +1025,7 @@ void CommandManager::SetKeyFromName(wxString name, wxString key)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandManager::SetKeyFromIndex(int i, wxString key)
|
||||
void CommandManager::SetKeyFromIndex(int i, const wxString &key)
|
||||
{
|
||||
const auto &entry = mCommandList[i];
|
||||
entry->key = KeyStringNormalize(key);
|
||||
@ -1284,7 +1284,7 @@ void CommandManager::GetAllCommandData(
|
||||
}
|
||||
}
|
||||
}
|
||||
wxString CommandManager::GetLabelFromName(wxString name)
|
||||
wxString CommandManager::GetLabelFromName(const wxString &name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry)
|
||||
@ -1293,7 +1293,7 @@ wxString CommandManager::GetLabelFromName(wxString name)
|
||||
return entry->label;
|
||||
}
|
||||
|
||||
wxString CommandManager::GetPrefixedLabelFromName(wxString name)
|
||||
wxString CommandManager::GetPrefixedLabelFromName(const wxString &name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry)
|
||||
@ -1310,7 +1310,7 @@ wxString CommandManager::GetPrefixedLabelFromName(wxString name)
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString CommandManager::GetCategoryFromName(wxString name)
|
||||
wxString CommandManager::GetCategoryFromName(const wxString &name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry)
|
||||
@ -1319,7 +1319,7 @@ wxString CommandManager::GetCategoryFromName(wxString name)
|
||||
return entry->labelTop;
|
||||
}
|
||||
|
||||
wxString CommandManager::GetKeyFromName(wxString name)
|
||||
wxString CommandManager::GetKeyFromName(const wxString &name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry)
|
||||
@ -1328,7 +1328,7 @@ wxString CommandManager::GetKeyFromName(wxString name)
|
||||
return entry->key;
|
||||
}
|
||||
|
||||
wxString CommandManager::GetDefaultKeyFromName(wxString name)
|
||||
wxString CommandManager::GetDefaultKeyFromName(const wxString &name)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
if (!entry)
|
||||
@ -1411,7 +1411,7 @@ void CommandManager::SetDefaultFlags(wxUint32 flags, wxUint32 mask)
|
||||
mDefaultMask = mask;
|
||||
}
|
||||
|
||||
void CommandManager::SetCommandFlags(wxString name,
|
||||
void CommandManager::SetCommandFlags(const wxString &name,
|
||||
wxUint32 flags, wxUint32 mask)
|
||||
{
|
||||
CommandListEntry *entry = mCommandNameHash[name];
|
||||
|
@ -184,7 +184,7 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
// For NEW items/commands
|
||||
void SetDefaultFlags(wxUint32 flags, wxUint32 mask);
|
||||
|
||||
void SetCommandFlags(wxString name, wxUint32 flags, wxUint32 mask);
|
||||
void SetCommandFlags(const wxString &name, wxUint32 flags, wxUint32 mask);
|
||||
void SetCommandFlags(const wxChar **names,
|
||||
wxUint32 flags, wxUint32 mask);
|
||||
// Pass multiple command names as const wxChar *, terminated by NULL
|
||||
@ -195,16 +195,16 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
//
|
||||
|
||||
void EnableUsingFlags(wxUint32 flags, wxUint32 mask);
|
||||
void Enable(wxString name, bool enabled);
|
||||
void Check(wxString name, bool checked);
|
||||
void Modify(wxString name, wxString newLabel);
|
||||
void Enable(const wxString &name, bool enabled);
|
||||
void Check(const wxString &name, bool checked);
|
||||
void Modify(const wxString &name, const wxString &newLabel);
|
||||
|
||||
//
|
||||
// Modifying accelerators
|
||||
//
|
||||
|
||||
void SetKeyFromName(wxString name, wxString key);
|
||||
void SetKeyFromIndex(int i, wxString key);
|
||||
void SetKeyFromName(const wxString &name, const wxString &key);
|
||||
void SetKeyFromIndex(int i, const wxString &key);
|
||||
|
||||
//
|
||||
// Executing commands
|
||||
@ -231,11 +231,11 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
||||
#endif
|
||||
bool includeMultis);
|
||||
|
||||
wxString GetLabelFromName(wxString name);
|
||||
wxString GetPrefixedLabelFromName(wxString name);
|
||||
wxString GetCategoryFromName(wxString name);
|
||||
wxString GetKeyFromName(wxString name);
|
||||
wxString GetDefaultKeyFromName(wxString name);
|
||||
wxString GetLabelFromName(const wxString &name);
|
||||
wxString GetPrefixedLabelFromName(const wxString &name);
|
||||
wxString GetCategoryFromName(const wxString &name);
|
||||
wxString GetKeyFromName(const wxString &name);
|
||||
wxString GetDefaultKeyFromName(const wxString &name);
|
||||
|
||||
bool GetEnabled(const wxString &name);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class CommandMessageTarget
|
||||
{
|
||||
public:
|
||||
virtual ~CommandMessageTarget() {}
|
||||
virtual void Update(wxString message) = 0;
|
||||
virtual void Update(const wxString &message) = 0;
|
||||
};
|
||||
|
||||
///
|
||||
@ -93,7 +93,7 @@ class NullMessageTarget : public CommandMessageTarget
|
||||
{
|
||||
public:
|
||||
virtual ~NullMessageTarget() {}
|
||||
virtual void Update(wxString message) {}
|
||||
virtual void Update(const wxString &message) override {}
|
||||
};
|
||||
|
||||
/// Displays messages from a command in a wxMessageBox
|
||||
@ -101,7 +101,7 @@ class MessageBoxTarget : public CommandMessageTarget
|
||||
{
|
||||
public:
|
||||
virtual ~MessageBoxTarget() {}
|
||||
virtual void Update(wxString message)
|
||||
virtual void Update(const wxString &message) override
|
||||
{
|
||||
wxMessageBox(message);
|
||||
}
|
||||
@ -116,7 +116,7 @@ public:
|
||||
StatusBarTarget(wxStatusBar &sb)
|
||||
: mStatus(sb)
|
||||
{}
|
||||
virtual void Update(wxString message)
|
||||
virtual void Update(const wxString &message) override
|
||||
{
|
||||
mStatus.SetStatusText(message, 0);
|
||||
}
|
||||
@ -135,7 +135,7 @@ public:
|
||||
{
|
||||
mResponseQueue.AddResponse(wxString(wxT("\n")));
|
||||
}
|
||||
virtual void Update(wxString message)
|
||||
virtual void Update(const wxString &message) override
|
||||
{
|
||||
mResponseQueue.AddResponse(message);
|
||||
}
|
||||
@ -158,7 +158,7 @@ public:
|
||||
delete m1;
|
||||
delete m2;
|
||||
}
|
||||
virtual void Update(wxString message)
|
||||
virtual void Update(const wxString &message) override
|
||||
{
|
||||
m1->Update(message);
|
||||
m2->Update(message);
|
||||
@ -220,12 +220,12 @@ public:
|
||||
if (mProgressTarget)
|
||||
mProgressTarget->Update(completed);
|
||||
}
|
||||
void Status(wxString status)
|
||||
void Status(const wxString &status)
|
||||
{
|
||||
if (mStatusTarget)
|
||||
mStatusTarget->Update(status);
|
||||
}
|
||||
void Error(wxString message)
|
||||
void Error(const wxString &message)
|
||||
{
|
||||
if (mErrorTarget)
|
||||
mErrorTarget->Update(message);
|
||||
|
@ -152,7 +152,7 @@ static void Yield()
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenshotCommand::Capture(wxString filename,
|
||||
void ScreenshotCommand::Capture(const wxString &filename,
|
||||
wxWindow *window,
|
||||
int x, int y, int width, int height,
|
||||
bool bg)
|
||||
@ -226,7 +226,7 @@ void ScreenshotCommand::Capture(wxString filename,
|
||||
::wxBell();
|
||||
}
|
||||
|
||||
void ScreenshotCommand::CaptureToolbar(ToolManager *man, int type, wxString name)
|
||||
void ScreenshotCommand::CaptureToolbar(ToolManager *man, int type, const wxString &name)
|
||||
{
|
||||
bool visible = man->IsVisible(type);
|
||||
if (!visible) {
|
||||
@ -251,7 +251,7 @@ void ScreenshotCommand::CaptureToolbar(ToolManager *man, int type, wxString name
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenshotCommand::CaptureDock(wxWindow *win, wxString fileName)
|
||||
void ScreenshotCommand::CaptureDock(wxWindow *win, const wxString &fileName)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
int width, height;
|
||||
@ -311,7 +311,7 @@ Command *ScreenshotCommandType::Create(CommandOutputTarget *target)
|
||||
return new ScreenshotCommand(*this, target);
|
||||
}
|
||||
|
||||
wxString ScreenshotCommand::MakeFileName(wxString path, wxString basename)
|
||||
wxString ScreenshotCommand::MakeFileName(const wxString &path, const wxString &basename)
|
||||
{
|
||||
wxFileName prefixPath;
|
||||
prefixPath.AssignDir(path);
|
||||
|
@ -40,15 +40,15 @@ private:
|
||||
bool mBackground;
|
||||
wxColour mBackColor;
|
||||
|
||||
wxString MakeFileName(wxString path, wxString basename);
|
||||
wxString MakeFileName(const wxString &path, const wxString &basename);
|
||||
|
||||
wxRect GetBackgroundRect();
|
||||
void Capture(wxString basename,
|
||||
void Capture(const wxString &basename,
|
||||
wxWindow *window,
|
||||
int x, int y, int width, int height,
|
||||
bool bg = false);
|
||||
void CaptureToolbar(ToolManager *man, int type, wxString name);
|
||||
void CaptureDock(wxWindow *win, wxString fileName);
|
||||
void CaptureToolbar(ToolManager *man, int type, const wxString &name);
|
||||
void CaptureDock(wxWindow *win, const wxString &fileName);
|
||||
|
||||
public:
|
||||
wxTopLevelWindow *GetFrontWindow(AudacityProject *project);
|
||||
|
@ -75,7 +75,7 @@ bool SetProjectInfoCommand::Apply(CommandExecutionContext context)
|
||||
|
||||
|
||||
// *********************** Private Methods *******************
|
||||
void SetProjectInfoCommand::SetAllTracksParam(TrackList *projTracks, wxString boolValueStr, Setter functPtrToSetter)
|
||||
void SetProjectInfoCommand::SetAllTracksParam(TrackList *projTracks, const wxString &boolValueStr, Setter functPtrToSetter)
|
||||
{
|
||||
unsigned int i=0;
|
||||
TrackListIterator iter(projTracks);
|
||||
|
@ -48,7 +48,7 @@ private:
|
||||
typedef void (SetProjectInfoCommand::*Setter)(Track *trk, bool setting) const;
|
||||
|
||||
// Uses the Function pointer to set a particular parameter within a loop of otherwise duplicate code
|
||||
void SetAllTracksParam(TrackList *projTracks, wxString boolValueStr, Setter functPtrToSetter);
|
||||
void SetAllTracksParam(TrackList *projTracks, const wxString &boolValueStr, Setter functPtrToSetter);
|
||||
|
||||
// Function pointer to accessing a particular parameter within a loop of otherwise duplicate code
|
||||
void setSelected(Track *trk, bool setting) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user