From 4961006f1b235dd3ea23e6ace448be8baab2e886 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:15:35 -0500 Subject: [PATCH 1/9] Sweep unnecessary wxString copies: xml --- src/xml/XMLTagHandler.cpp | 4 ++-- src/xml/XMLTagHandler.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xml/XMLTagHandler.cpp b/src/xml/XMLTagHandler.cpp index f2f10469d..be053e280 100644 --- a/src/xml/XMLTagHandler.cpp +++ b/src/xml/XMLTagHandler.cpp @@ -62,7 +62,7 @@ bool XMLValueChecker::IsGoodFileName(const wxString & strFileName, const wxStrin return (fileName.IsOk() && fileName.FileExists()); } -bool XMLValueChecker::IsGoodFileString(wxString str) +bool XMLValueChecker::IsGoodFileString(const wxString &str) { return (IsGoodString(str) && !str.IsEmpty() && @@ -97,7 +97,7 @@ bool XMLValueChecker::IsGoodPathName(const wxString & strPathName) return XMLValueChecker::IsGoodFileName(fileName.GetFullName(), fileName.GetPath(wxPATH_GET_VOLUME)); } -bool XMLValueChecker::IsGoodPathString(wxString str) +bool XMLValueChecker::IsGoodPathString(const wxString &str) { return (IsGoodString(str) && !str.IsEmpty() && diff --git a/src/xml/XMLTagHandler.h b/src/xml/XMLTagHandler.h index 16d77b569..d31c21d41 100644 --- a/src/xml/XMLTagHandler.h +++ b/src/xml/XMLTagHandler.h @@ -32,10 +32,10 @@ public: static bool IsGoodString(const wxString & str); static bool IsGoodFileName(const wxString & strFileName, const wxString & strDirName = wxEmptyString); - static bool IsGoodFileString(wxString str); + static bool IsGoodFileString(const wxString &str); static bool IsGoodSubdirName(const wxString & strSubdirName, const wxString & strDirName = wxEmptyString); static bool IsGoodPathName(const wxString & strPathName); - static bool IsGoodPathString(wxString str); + static bool IsGoodPathString(const wxString &str); /** @brief Check that the supplied string can be converted to a long (32bit) * integer. From 2efa24bc10b347210dd556030743f6d3e9eafcd0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:16:12 -0500 Subject: [PATCH 2/9] Sweep unnecessary wxString copies: widgets --- src/widgets/ASlider.cpp | 8 ++++---- src/widgets/ASlider.h | 8 ++++---- src/widgets/MultiDialog.cpp | 6 +++--- src/widgets/MultiDialog.h | 6 +++--- src/widgets/NumericTextCtrl.cpp | 2 +- src/widgets/NumericTextCtrl.h | 2 +- src/widgets/Ruler.cpp | 2 +- src/widgets/Ruler.h | 2 +- src/widgets/Warning.cpp | 4 ++-- src/widgets/Warning.h | 4 ++-- src/widgets/numformatter.cpp | 27 +++++++++++++++++---------- src/widgets/numformatter.h | 8 ++++---- src/widgets/valnum.h | 5 +++-- 13 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index aa437b77b..ce6780ecc 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -342,7 +342,7 @@ static const wxPoint2DDouble disabledRightEnd[] = // Construct customizable slider LWSlider::LWSlider(wxWindow * parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, @@ -412,7 +412,7 @@ void LWSlider::SetStyle(int style) // Construct predefined slider LWSlider::LWSlider(wxWindow *parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, int style, @@ -475,7 +475,7 @@ LWSlider::LWSlider(wxWindow *parent, } void LWSlider::Init(wxWindow * parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, @@ -1582,7 +1582,7 @@ END_EVENT_TABLE() ASlider::ASlider( wxWindow * parent, wxWindowID id, - wxString name, + const wxString &name, const wxPoint & pos, const wxSize & size, int style, diff --git a/src/widgets/ASlider.h b/src/widgets/ASlider.h index cc79fc260..daa2f0558 100644 --- a/src/widgets/ASlider.h +++ b/src/widgets/ASlider.h @@ -78,7 +78,7 @@ class LWSlider // MM: Construct customizable slider LWSlider(wxWindow * parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, @@ -92,7 +92,7 @@ class LWSlider // Construct predefined slider LWSlider(wxWindow * parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, int style, @@ -101,7 +101,7 @@ class LWSlider int orientation = wxHORIZONTAL); // wxHORIZONTAL or wxVERTICAL. wxVERTICAL is currently only for DB_SLIDER. void Init(wxWindow * parent, - wxString name, + const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, @@ -255,7 +255,7 @@ class ASlider :public wxPanel public: ASlider( wxWindow * parent, wxWindowID id, - wxString name, + const wxString &name, const wxPoint & pos, const wxSize & size, int style = FRAC_SLIDER, diff --git a/src/widgets/MultiDialog.cpp b/src/widgets/MultiDialog.cpp index 1548266eb..e3f05a0b3 100644 --- a/src/widgets/MultiDialog.cpp +++ b/src/widgets/MultiDialog.cpp @@ -156,9 +156,9 @@ void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event)) } -int ShowMultiDialog(wxString message, - wxString title, - const wxChar **buttons, wxString boxMsg, bool log) +int ShowMultiDialog(const wxString &message, + const wxString &title, + const wxChar **buttons, const wxString &boxMsg, bool log) { wxWindow * pParent = wxGetApp().GetTopWindow(); diff --git a/src/widgets/MultiDialog.h b/src/widgets/MultiDialog.h index 741ebf4bd..4090f6d48 100644 --- a/src/widgets/MultiDialog.h +++ b/src/widgets/MultiDialog.h @@ -19,8 +19,8 @@ // Display a dialog with radio buttons. // Return the zero-based index of the chosen button. -int ShowMultiDialog(wxString message, - wxString title, - const wxChar **buttons, wxString boxMsg = _("Please select an action"), bool log = true); +int ShowMultiDialog(const wxString &message, + const wxString &title, + const wxChar **buttons, const wxString &boxMsg = _("Please select an action"), bool log = true); #endif // __AUDACITY_MULTIDIALOG__ diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index a4dfbb5f6..055baa5d7 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -1163,7 +1163,7 @@ IMPLEMENT_CLASS(NumericTextCtrl, wxControl) NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type, wxWindow *parent, wxWindowID id, - wxString formatName, + const wxString &formatName, double timeValue, double sampleRate, const wxPoint &pos, diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index be5c8d495..ce445100b 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -136,7 +136,7 @@ class NumericTextCtrl: public wxControl, public NumericConverter NumericTextCtrl(NumericConverter::Type type, wxWindow *parent, wxWindowID id, - wxString formatName = wxEmptyString, + const wxString &formatName = wxEmptyString, double value = 0.0, double sampleRate = 44100, const wxPoint &pos = wxDefaultPosition, diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 8e66473f1..d74ecd10c 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -204,7 +204,7 @@ void Ruler::SetLog(bool log) } } -void Ruler::SetUnits(wxString units) +void Ruler::SetUnits(const wxString &units) { // Specify the name of the units (like "dB") if you // want numbers like "1.6" formatted as "1.6 dB". diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index ed7f06120..e07ae3575 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -79,7 +79,7 @@ class AUDACITY_DLL_API Ruler { // Specify the name of the units (like "dB") if you // want numbers like "1.6" formatted as "1.6 dB". - void SetUnits(wxString units); + void SetUnits(const wxString &units); // Logarithmic void SetLog(bool log); diff --git a/src/widgets/Warning.cpp b/src/widgets/Warning.cpp index a552d4579..2afe95c0e 100644 --- a/src/widgets/Warning.cpp +++ b/src/widgets/Warning.cpp @@ -81,8 +81,8 @@ void WarningDialog::OnOK(wxCommandEvent& WXUNUSED(event)) } int ShowWarningDialog(wxWindow *parent, - wxString internalDialogName, - wxString message, + const wxString &internalDialogName, + const wxString &message, bool showCancelButton) { wxString key(wxT("/Warnings/") + internalDialogName); diff --git a/src/widgets/Warning.h b/src/widgets/Warning.h index 1f87cf9ed..666a7ec0a 100644 --- a/src/widgets/Warning.h +++ b/src/widgets/Warning.h @@ -21,8 +21,8 @@ /// preferences. The internalDialogName is never seen by /// the user; it should be unique to each message. int ShowWarningDialog(wxWindow *parent, - wxString internalDialogName, - wxString message, + const wxString &internalDialogName, + const wxString &message, bool showCancelButton = false); #endif // __AUDACITY_WARNING__ diff --git a/src/widgets/numformatter.cpp b/src/widgets/numformatter.cpp index 792768c7a..dfbf19151 100644 --- a/src/widgets/numformatter.cpp +++ b/src/widgets/numformatter.cpp @@ -88,8 +88,10 @@ bool NumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep) // Conversion to string and helpers // ---------------------------------------------------------------------------- -wxString NumberFormatter::PostProcessIntString(wxString s, int style) +wxString NumberFormatter::PostProcessIntString(const wxString &sArg, int style) { + wxString s(sArg); + if ( style & Style_WithThousandsSep ) AddThousandsSeparators(s); @@ -226,24 +228,29 @@ void NumberFormatter::RemoveThousandsSeparators(wxString& s) s.Replace(wxString(thousandsSep), wxString()); } -bool NumberFormatter::FromString(wxString s, long *val) +bool NumberFormatter::FromString(const wxString &sArg, long *val) { - RemoveThousandsSeparators(s); - return s.ToLong(val); + wxString s(sArg); + RemoveThousandsSeparators(s); + return s.ToLong(val); } #ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG -bool NumberFormatter::FromString(wxString s, wxLongLong_t *val) +bool NumberFormatter::FromString(const wxString &sArg, wxLongLong_t *val) { - RemoveThousandsSeparators(s); - return s.ToLongLong(val); + wxString s(sArg); + + RemoveThousandsSeparators(s); + return s.ToLongLong(val); } #endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG -bool NumberFormatter::FromString(wxString s, double *val) +bool NumberFormatter::FromString(const wxString &sArg, double *val) { - RemoveThousandsSeparators(s); - return s.ToDouble(val); + wxString s(sArg); + + RemoveThousandsSeparators(s); + return s.ToDouble(val); } diff --git a/src/widgets/numformatter.h b/src/widgets/numformatter.h index b54dc7468..6d98315fc 100644 --- a/src/widgets/numformatter.h +++ b/src/widgets/numformatter.h @@ -51,11 +51,11 @@ public: // // Return true on success and stores the result in the provided location // which must be a valid non-NULL pointer. - static bool FromString(wxString s, long *val); + static bool FromString(const wxString &s, long *val); #ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static bool FromString(wxString s, wxLongLong_t *val); + static bool FromString(const wxString &s, wxLongLong_t *val); #endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG - static bool FromString(wxString s, double *val); + static bool FromString(const wxString &s, double *val); // Get the decimal separator for the current locale. It is always defined @@ -69,7 +69,7 @@ public: private: // Post-process the string representing an integer. - static wxString PostProcessIntString(wxString s, int style); + static wxString PostProcessIntString(const wxString &s, int style); // Add the thousands separators to a string representing a number without // the separators. This is used by ToString(Style_WithThousandsSep). diff --git a/src/widgets/valnum.h b/src/widgets/valnum.h index 0e72d52bf..7f3c6e112 100644 --- a/src/widgets/valnum.h +++ b/src/widgets/valnum.h @@ -84,8 +84,9 @@ protected: // Return the string which would result from inserting the given character // at the specified position. - wxString GetValueAfterInsertingChar(wxString val, int pos, wxChar ch) const + wxString GetValueAfterInsertingChar(const wxString &valArg, int pos, wxChar ch) const { + wxString val(valArg); val.insert(pos, ch); return val; } @@ -236,7 +237,7 @@ protected: { LongestValueType value; return BaseValidator::FromString(s, &value) ? NormalizeValue(value) - : wxString(); + : wxEmptyString; } private: From 0ce4fe0b836de66cc9eaa52955cf33ed6a223032 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:16:26 -0500 Subject: [PATCH 3/9] Sweep unnecessary wxString copies: prefs --- src/prefs/ModulePrefs.cpp | 4 ++-- src/prefs/ModulePrefs.h | 4 ++-- src/prefs/PrefsDialog.cpp | 2 +- src/prefs/PrefsDialog.h | 2 +- src/prefs/PrefsPanel.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index ddd8f69cd..676d6ff0a 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -138,7 +138,7 @@ bool ModulePrefs::Apply() // static function that tells us about a module. -int ModulePrefs::GetModuleStatus( wxString fname ){ +int ModulePrefs::GetModuleStatus(const wxString &fname){ // Default status is NEW module, and we will ask once. int iStatus = kModuleNew; @@ -152,7 +152,7 @@ int ModulePrefs::GetModuleStatus( wxString fname ){ return iStatus; } -void ModulePrefs::SetModuleStatus( wxString fname, int iStatus ){ +void ModulePrefs::SetModuleStatus(const wxString &fname, int iStatus){ wxString ShortName = wxFileName( fname ).GetName(); wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower(); gPrefs->Write( PrefName, iStatus ); diff --git a/src/prefs/ModulePrefs.h b/src/prefs/ModulePrefs.h index 09d80a1d2..2c042d93d 100644 --- a/src/prefs/ModulePrefs.h +++ b/src/prefs/ModulePrefs.h @@ -38,8 +38,8 @@ class ModulePrefs:public PrefsPanel ~ModulePrefs(); virtual bool Apply(); - static int GetModuleStatus( wxString fname ); - static void SetModuleStatus( wxString fname, int iStatus ); + static int GetModuleStatus( const wxString &fname ); + static void SetModuleStatus( const wxString &fname, int iStatus ); private: void GetAllModuleStatuses(); diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index c7749ecb0..2dfe0602a 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -448,7 +448,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event)) EndModal(true); } -void PrefsDialog::SelectPageByName(wxString pageName) +void PrefsDialog::SelectPageByName(const wxString &pageName) { if (mCategories) { size_t n = mCategories->GetPageCount(); diff --git a/src/prefs/PrefsDialog.h b/src/prefs/PrefsDialog.h index 42bbf89f1..13c7092fa 100644 --- a/src/prefs/PrefsDialog.h +++ b/src/prefs/PrefsDialog.h @@ -61,7 +61,7 @@ class PrefsDialog:public wxDialog void OnApply(wxCommandEvent & e); void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree - void SelectPageByName(wxString pageName); + void SelectPageByName(const wxString &pageName); // Accessor to help implementations of SavePreferredPage(), // such as by saving a preference after DoModal() returns diff --git a/src/prefs/PrefsPanel.h b/src/prefs/PrefsPanel.h index 77da3a042..245f2f122 100644 --- a/src/prefs/PrefsPanel.h +++ b/src/prefs/PrefsPanel.h @@ -43,7 +43,7 @@ ThemePrefs. class PrefsPanel:public wxPanel { public: - PrefsPanel(wxWindow * parent, wxString title) + PrefsPanel(wxWindow * parent, const wxString &title) : wxPanel(parent, wxID_ANY) { SetLabel(title); // Provide visual label From d21c0aa4788667abc6dc16b6e1594e7c7a7487c7 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:16:39 -0500 Subject: [PATCH 4/9] Sweep unnecessary wxString copies: import --- src/import/Import.cpp | 2 +- src/import/Import.h | 4 ++-- src/import/ImportFFmpeg.cpp | 4 ++-- src/import/ImportFLAC.cpp | 4 ++-- src/import/ImportLOF.cpp | 4 ++-- src/import/ImportMIDI.cpp | 2 +- src/import/ImportMIDI.h | 2 +- src/import/ImportMP3.cpp | 4 ++-- src/import/ImportOGG.cpp | 4 ++-- src/import/ImportPCM.cpp | 4 ++-- src/import/ImportPlugin.h | 8 ++++---- src/import/ImportRaw.cpp | 2 +- src/import/ImportRaw.h | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/import/Import.cpp b/src/import/Import.cpp index b944b10e4..46235bfb6 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -348,7 +348,7 @@ ExtImportItem *Importer::CreateDefaultImportItem() } // returns number of tracks imported -int Importer::Import(wxString fName, +int Importer::Import(const wxString &fName, TrackFactory *trackFactory, Track *** tracks, Tags *tags, diff --git a/src/import/Import.h b/src/import/Import.h index 777564ef5..a46179d3d 100644 --- a/src/import/Import.h +++ b/src/import/Import.h @@ -31,7 +31,7 @@ public: wxString formatName; wxArrayString formatExtensions; - Format(wxString _formatName, wxArrayString _formatExtensions): + Format(const wxString &_formatName, const wxArrayString &_formatExtensions): formatName(_formatName), formatExtensions(_formatExtensions) { @@ -139,7 +139,7 @@ public: // returns number of tracks imported // if zero, the import failed and errorMessage will be set. - int Import(wxString fName, + int Import(const wxString &fName, TrackFactory *trackFactory, Track *** tracks, Tags *tags, diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index ed50a5252..eff68d88e 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -182,7 +182,7 @@ public: wxString GetPluginFormatDescription(); ///! Probes the file and opens it if appropriate - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; ///! Does acual import, returned by FFmpegImportPlugin::Open @@ -292,7 +292,7 @@ wxString FFmpegImportPlugin::GetPluginFormatDescription() return DESC; } -ImportFileHandle *FFmpegImportPlugin::Open(wxString filename) +ImportFileHandle *FFmpegImportPlugin::Open(const wxString &filename) { FFmpegImportFileHandle *handle = new FFmpegImportFileHandle(filename); diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 68aeed17d..cb4db3646 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -138,7 +138,7 @@ class FLACImportPlugin : public ImportPlugin wxString GetPluginStringID() { return wxT("libflac"); } wxString GetPluginFormatDescription(); - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; @@ -289,7 +289,7 @@ wxString FLACImportPlugin::GetPluginFormatDescription() } -ImportFileHandle *FLACImportPlugin::Open(wxString filename) +ImportFileHandle *FLACImportPlugin::Open(const wxString &filename) { // First check if it really is a FLAC file diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index 8321cd476..7c70be5d3 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -113,7 +113,7 @@ public: wxString GetPluginStringID() { return wxT("lof"); } wxString GetPluginFormatDescription(); - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; @@ -181,7 +181,7 @@ wxString LOFImportPlugin::GetPluginFormatDescription() return DESC; } -ImportFileHandle *LOFImportPlugin::Open(wxString filename) +ImportFileHandle *LOFImportPlugin::Open(const wxString &filename) { // Check if it is a binary file wxFile binaryFile; diff --git a/src/import/ImportMIDI.cpp b/src/import/ImportMIDI.cpp index e03aff042..1b593b988 100644 --- a/src/import/ImportMIDI.cpp +++ b/src/import/ImportMIDI.cpp @@ -25,7 +25,7 @@ #include "../NoteTrack.h" #include "ImportMIDI.h" -bool ImportMIDI(wxString fName, NoteTrack * dest) +bool ImportMIDI(const wxString &fName, NoteTrack * dest) { if (fName.Length() <= 4){ wxMessageBox( _("Could not open file ") + fName + _(": Filename too short.")); diff --git a/src/import/ImportMIDI.h b/src/import/ImportMIDI.h index 1abf35135..1c596d2ce 100644 --- a/src/import/ImportMIDI.h +++ b/src/import/ImportMIDI.h @@ -24,7 +24,7 @@ into a NoteTrack. class NoteTrack; -bool ImportMIDI(wxString fName, NoteTrack * dest); +bool ImportMIDI(const wxString &fName, NoteTrack * dest); class MIDIParser { public: diff --git a/src/import/ImportMP3.cpp b/src/import/ImportMP3.cpp index 2c1087050..79db0ac42 100644 --- a/src/import/ImportMP3.cpp +++ b/src/import/ImportMP3.cpp @@ -114,7 +114,7 @@ public: wxString GetPluginStringID() { return wxT("libmad"); } wxString GetPluginFormatDescription(); - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; class MP3ImportFileHandle : public ImportFileHandle @@ -176,7 +176,7 @@ wxString MP3ImportPlugin::GetPluginFormatDescription() return DESC; } -ImportFileHandle *MP3ImportPlugin::Open(wxString Filename) +ImportFileHandle *MP3ImportPlugin::Open(const wxString &Filename) { wxFile *file = new wxFile(Filename); diff --git a/src/import/ImportOGG.cpp b/src/import/ImportOGG.cpp index 78aa0902b..84d69ac4b 100644 --- a/src/import/ImportOGG.cpp +++ b/src/import/ImportOGG.cpp @@ -92,7 +92,7 @@ public: wxString GetPluginStringID() { return wxT("liboggvorbis"); } wxString GetPluginFormatDescription(); - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; @@ -171,7 +171,7 @@ wxString OggImportPlugin::GetPluginFormatDescription() return DESC; } -ImportFileHandle *OggImportPlugin::Open(wxString filename) +ImportFileHandle *OggImportPlugin::Open(const wxString &filename) { OggVorbis_File *vorbisFile = new OggVorbis_File; wxFFile *file = new wxFFile(filename, wxT("rb")); diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 90b5e3957..3d8f383d0 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -82,7 +82,7 @@ public: wxString GetPluginStringID() { return wxT("libsndfile"); } wxString GetPluginFormatDescription(); - ImportFileHandle *Open(wxString Filename); + ImportFileHandle *Open(const wxString &Filename) override; }; @@ -120,7 +120,7 @@ wxString PCMImportPlugin::GetPluginFormatDescription() return DESC; } -ImportFileHandle *PCMImportPlugin::Open(wxString filename) +ImportFileHandle *PCMImportPlugin::Open(const wxString &filename) { SF_INFO info; SNDFILE *file = NULL; diff --git a/src/import/ImportPlugin.h b/src/import/ImportPlugin.h index ce5ec31a6..9c733d1b5 100644 --- a/src/import/ImportPlugin.h +++ b/src/import/ImportPlugin.h @@ -90,7 +90,7 @@ public: return mExtensions; } - bool SupportsExtension(wxString extension) + bool SupportsExtension(const wxString &extension) { // Case-insensitive check if extension is supported return mExtensions.Index(extension, false) != wxNOT_FOUND; @@ -99,7 +99,7 @@ public: // Open the given file, returning true if it is in a recognized // format, false otherwise. This puts the importer into the open // state. - virtual ImportFileHandle *Open(wxString Filename) = 0; + virtual ImportFileHandle *Open(const wxString &Filename) = 0; virtual ~ImportPlugin() { } @@ -178,7 +178,7 @@ protected: class UnusableImportPlugin { public: - UnusableImportPlugin(wxString formatName, wxArrayString extensions): + UnusableImportPlugin(const wxString &formatName, wxArrayString extensions): mFormatName(formatName), mExtensions(extensions) { @@ -189,7 +189,7 @@ public: return mFormatName; } - bool SupportsExtension(wxString extension) + bool SupportsExtension(const wxString &extension) { return mExtensions.Index(extension, false) != wxNOT_FOUND; } diff --git a/src/import/ImportRaw.cpp b/src/import/ImportRaw.cpp index 683335056..7fc6ad10d 100644 --- a/src/import/ImportRaw.cpp +++ b/src/import/ImportRaw.cpp @@ -93,7 +93,7 @@ class ImportRawDialog:public wxDialog { DECLARE_EVENT_TABLE() }; -int ImportRaw(wxWindow *parent, wxString fileName, +int ImportRaw(wxWindow *parent, const wxString &fileName, TrackFactory *trackFactory, Track ***outTracks) { int encoding = 0; // Guess Format diff --git a/src/import/ImportRaw.h b/src/import/ImportRaw.h index 3ca297734..2ff5b6927 100644 --- a/src/import/ImportRaw.h +++ b/src/import/ImportRaw.h @@ -17,7 +17,7 @@ class WaveTrack; class DirManager; class wxWindow; -int ImportRaw(wxWindow *parent, wxString fileName, +int ImportRaw(wxWindow *parent, const wxString &fileName, TrackFactory *trackFactory, Track ***outTracks); #endif From 83e8a80f61cecbc1164a17147a7d71d96881c036 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:17:04 -0500 Subject: [PATCH 5/9] Sweep unnecessary wxString copies: export --- src/export/Export.cpp | 31 +------------------------------ src/export/Export.h | 15 +++------------ src/export/ExportCL.cpp | 6 +++--- src/export/ExportFFmpeg.cpp | 6 +++--- src/export/ExportFLAC.cpp | 6 +++--- src/export/ExportMP2.cpp | 6 +++--- src/export/ExportMP3.cpp | 6 +++--- src/export/ExportMultiple.cpp | 6 +++--- src/export/ExportMultiple.h | 6 +++--- src/export/ExportOGG.cpp | 6 +++--- src/export/ExportPCM.cpp | 6 +++--- 11 files changed, 31 insertions(+), 69 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index a95c06541..b19ea8b16 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -242,35 +242,6 @@ wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format)) return p; } -int ExportPlugin::Export(AudacityProject *project, - int channels, - wxString fName, - bool selectedOnly, - double t0, - double t1, - MixerSpec *mixerSpec, - Tags * WXUNUSED(metadata), - int subformat) -{ - if (project == NULL) { - project = GetActiveProject(); - } - - return DoExport(project, channels, fName, selectedOnly, t0, t1, mixerSpec, subformat); -} - -int ExportPlugin::DoExport(AudacityProject * WXUNUSED(project), - int WXUNUSED(channels), - wxString WXUNUSED(fName), - bool WXUNUSED(selectedOnly), - double WXUNUSED(t0), - double WXUNUSED(t1), - MixerSpec * WXUNUSED(mixerSpec), - int WXUNUSED(subformat)) -{ - return false; -} - //Create a mixer by computing the time warp factor Mixer* ExportPlugin::CreateMixer(int numInputTracks, WaveTrack **inputTracks, TimeTrack *timeTrack, @@ -952,7 +923,7 @@ ExportMixerPanel::~ExportMixerPanel() } //set the font on memDC such that text can fit in specified width and height -void ExportMixerPanel::SetFont( wxMemoryDC &memDC, wxString text, int width, +void ExportMixerPanel::SetFont(wxMemoryDC &memDC, const wxString &text, int width, int height ) { int l = 0, u = 13, m, w, h; diff --git a/src/export/Export.h b/src/export/Export.h index 38cfa0340..c3b6e2a5f 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -105,22 +105,13 @@ public: */ virtual int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); - - virtual int DoExport(AudacityProject *project, - int channels, - wxString fName, - bool selectedOnly, - double t0, - double t1, - MixerSpec *mixerSpec, - int subformat); + int subformat = 0) = 0; protected: Mixer* CreateMixer(int numInputTracks, WaveTrack **inputTracks, @@ -227,7 +218,7 @@ private: wxArrayString mTrackNames; int mBoxWidth, mChannelHeight, mTrackHeight; - void SetFont( wxMemoryDC &memDC, wxString text, int width, int height ); + void SetFont( wxMemoryDC &memDC, const wxString &text, int width, int height ); double Distance( wxPoint &a, wxPoint &b ); bool IsOnLine( wxPoint p, wxPoint la, wxPoint lb ); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index e75d1aa91..fe85c6a3e 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -286,13 +286,13 @@ public: int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; }; ExportCL::ExportCL() @@ -313,7 +313,7 @@ void ExportCL::Destroy() int ExportCL::Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectionOnly, double t0, double t1, diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 6913de72e..886aeb62e 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -140,13 +140,13 @@ public: ///\return true if export succeded int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; private: @@ -791,7 +791,7 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, int frameSize) int ExportFFmpeg::Export(AudacityProject *project, - int channels, wxString fName, + int channels, const wxString &fName, bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, Tags *metadata, int subformat) { if (!CheckFFmpegPresence()) diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index b44d78c1e..0d62a736a 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -185,13 +185,13 @@ public: wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; private: @@ -220,7 +220,7 @@ void ExportFLAC::Destroy() int ExportFLAC::Export(AudacityProject *project, int numChannels, - wxString fName, + const wxString &fName, bool selectionOnly, double t0, double t1, diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index 1388fdd0c..04eb8c3fc 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -176,13 +176,13 @@ public: wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; private: @@ -210,7 +210,7 @@ void ExportMP2::Destroy() } int ExportMP2::Export(AudacityProject *project, - int channels, wxString fName, + int channels, const wxString &fName, bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, Tags *metadata, int WXUNUSED(subformat)) { diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 9ca54cab2..c65ceb619 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1564,13 +1564,13 @@ public: wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; private: @@ -1619,7 +1619,7 @@ bool ExportMP3::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(form int ExportMP3::Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectionOnly, double t0, double t1, diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index d05f6a266..5d0382eab 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -619,7 +619,7 @@ bool ExportMultiple::DirOk() } int ExportMultiple::ExportMultipleByLabel(bool byName, - wxString prefix, bool addNumber) + const wxString &prefix, bool addNumber) { wxASSERT(mProject); bool tagsPrompt = mProject->GetShowId3Dialog(); @@ -737,7 +737,7 @@ int ExportMultiple::ExportMultipleByLabel(bool byName, } int ExportMultiple::ExportMultipleByTrack(bool byName, - wxString prefix, bool addNumber) + const wxString &prefix, bool addNumber) { wxASSERT(mProject); bool tagsPrompt = mProject->GetShowId3Dialog(); @@ -953,7 +953,7 @@ int ExportMultiple::DoExport(int channels, return success; } -wxString ExportMultiple::MakeFileName(wxString input) +wxString ExportMultiple::MakeFileName(const wxString &input) { wxString newname; // name we are generating diff --git a/src/export/ExportMultiple.h b/src/export/ExportMultiple.h index aba865cd5..6771a6922 100644 --- a/src/export/ExportMultiple.h +++ b/src/export/ExportMultiple.h @@ -54,7 +54,7 @@ private: * labels that define them (true), or just numbered (false). * @param prefix The string used to prefix the file number if files are being * numbered rather than named */ - int ExportMultipleByLabel(bool byName, wxString prefix, bool addNumber); + int ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber); /** \brief Export each track in the project to a separate file * @@ -62,7 +62,7 @@ private: * (true), or just numbered (false). * @param prefix The string used to prefix the file number if files are being * numbered rather than named */ - int ExportMultipleByTrack(bool byName, wxString prefix, bool addNumber); + int ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber); /** Export one file of an export multiple set * @@ -83,7 +83,7 @@ private: /** \brief Takes an arbitrary text string and converts it to a form that can * be used as a file name, if necessary prompting the user to edit the file * name produced */ - wxString MakeFileName(wxString input); + wxString MakeFileName(const wxString &input); // Dialog void PopulateOrExchange(ShuttleGui& S); void EnableControls(); diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index d54da57fd..3c2c5fdbe 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -135,13 +135,13 @@ public: int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; private: @@ -166,7 +166,7 @@ void ExportOGG::Destroy() int ExportOGG::Export(AudacityProject *project, int numChannels, - wxString fName, + const wxString &fName, bool selectionOnly, double t0, double t1, diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index e5fa34cfb..e5fdcc7a9 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -315,13 +315,13 @@ public: wxWindow *OptionsCreate(wxWindow *parent, int format); int Export(AudacityProject *project, int channels, - wxString fName, + const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec = NULL, Tags *metadata = NULL, - int subformat = 0); + int subformat = 0) override; // optional wxString GetExtension(int index); virtual bool CheckFileName(wxFileName &filename, int format); @@ -390,7 +390,7 @@ void ExportPCM::Destroy() */ int ExportPCM::Export(AudacityProject *project, int numChannels, - wxString fName, + const wxString &fName, bool selectionOnly, double t0, double t1, From 99f161c36c2d6c81b5eb42794b10be8bc48088f0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:17:19 -0500 Subject: [PATCH 6/9] Sweep unnecessary wxString copies: effects --- src/effects/Effect.cpp | 4 ++-- src/effects/Effect.h | 4 ++-- src/effects/Equalization.cpp | 8 ++++---- src/effects/Equalization.h | 8 ++++---- src/effects/Normalize.cpp | 6 +++--- src/effects/Normalize.h | 6 +++--- src/effects/VST/VSTEffect.cpp | 2 +- src/effects/VST/VSTEffect.h | 2 +- src/effects/nyquist/Nyquist.cpp | 14 +++++++------- src/effects/nyquist/Nyquist.h | 12 ++++++------ 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 04cd5365a..d1e9200ab 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2022,7 +2022,7 @@ bool Effect::TotalProgress(double frac) return (updateResult != eProgressSuccess); } -bool Effect::TrackProgress(int whichTrack, double frac, wxString msg) +bool Effect::TrackProgress(int whichTrack, double frac, const wxString &msg) { int updateResult = (mProgress ? mProgress->Update(whichTrack + frac, (double) mNumTracks, msg) : @@ -2030,7 +2030,7 @@ bool Effect::TrackProgress(int whichTrack, double frac, wxString msg) return (updateResult != eProgressSuccess); } -bool Effect::TrackGroupProgress(int whichGroup, double frac, wxString msg) +bool Effect::TrackGroupProgress(int whichGroup, double frac, const wxString &msg) { int updateResult = (mProgress ? mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) : diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 75a9ddcf5..83e2cf0b1 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -309,11 +309,11 @@ protected: // Pass a fraction between 0.0 and 1.0, for the current track // (when doing one track at a time) - bool TrackProgress(int whichTrack, double frac, wxString = wxT("")); + bool TrackProgress(int whichTrack, double frac, const wxString & = wxEmptyString); // Pass a fraction between 0.0 and 1.0, for the current track group // (when doing stereo groups at a time) - bool TrackGroupProgress(int whichGroup, double frac, wxString = wxT("")); + bool TrackGroupProgress(int whichGroup, double frac, const wxString & = wxEmptyString); int GetNumWaveTracks() { return mNumTracks; } diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 869cc13ec..3947a202e 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -1362,7 +1362,7 @@ void EffectEqualization::Filter(sampleCount len, float *buffer) // // Load external curves with fallback to default, then message // -void EffectEqualization::LoadCurves(wxString fileName, bool append) +void EffectEqualization::LoadCurves(const wxString &fileName, bool append) { // Construct normal curve filename // @@ -1460,7 +1460,7 @@ void EffectEqualization::LoadCurves(wxString fileName, bool append) // // Save curves to external file // -void EffectEqualization::SaveCurves(wxString fileName) +void EffectEqualization::SaveCurves(const wxString &fileName) { wxFileName fn; if( fileName == wxT("")) @@ -1601,7 +1601,7 @@ void EffectEqualization::setCurve() setCurve((int) mCurves.GetCount()-1); } -void EffectEqualization::setCurve(wxString curveName) +void EffectEqualization::setCurve(const wxString &curveName) { unsigned i = 0; for( i = 0; i < mCurves.GetCount(); i++ ) @@ -3456,7 +3456,7 @@ void EditCurvesDialog::OnOK(wxCommandEvent & WXUNUSED(event)) #if wxUSE_ACCESSIBILITY -SliderAx::SliderAx( wxWindow * window, wxString fmt ): +SliderAx::SliderAx(wxWindow * window, const wxString &fmt) : wxWindowAccessible( window ) { mParent = window; diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index 52829e257..65ddae598 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -141,11 +141,11 @@ private: void EnvelopeUpdated(Envelope *env, bool lin); bool IsLinear(); - void LoadCurves(wxString fileName = wxT(""), bool append = false); - void SaveCurves(wxString fileName = wxT("")); + void LoadCurves(const wxString &fileName = wxEmptyString, bool append = false); + void SaveCurves(const wxString &fileName = wxEmptyString); void Select(int sel); void setCurve(int currentCurve); - void setCurve(wxString curveName); + void setCurve(const wxString &curveName); void setCurve(void); // XMLTagHandler callback methods for loading and saving @@ -367,7 +367,7 @@ private: class SliderAx: public wxWindowAccessible { public: - SliderAx(wxWindow * window, wxString fmt); + SliderAx(wxWindow * window, const wxString &fmt); virtual ~ SliderAx(); diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index bee0e1127..bb572b042 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -333,7 +333,7 @@ bool EffectNormalize::TransferDataFromWindow() // EffectNormalize implementation -void EffectNormalize::AnalyseTrack(WaveTrack * track, wxString msg) +void EffectNormalize::AnalyseTrack(WaveTrack * track, const wxString &msg) { if(mGain) { // Since we need complete summary data, we need to block until the OD tasks are done for this track @@ -361,7 +361,7 @@ void EffectNormalize::AnalyseTrack(WaveTrack * track, wxString msg) //AnalyseDC() takes a track, transforms it to bunch of buffer-blocks, //and executes AnalyzeData on it... // sets mOffset -bool EffectNormalize::AnalyseDC(WaveTrack * track, wxString msg) +bool EffectNormalize::AnalyseDC(WaveTrack * track, const wxString &msg) { bool rc = true; sampleCount s; @@ -427,7 +427,7 @@ bool EffectNormalize::AnalyseDC(WaveTrack * track, wxString msg) //ProcessOne() takes a track, transforms it to bunch of buffer-blocks, //and executes ProcessData, on it... // uses mMult and mOffset to normalize a track. Needs to have them set before being called -bool EffectNormalize::ProcessOne(WaveTrack * track, wxString msg) +bool EffectNormalize::ProcessOne(WaveTrack * track, const wxString &msg) { bool rc = true; sampleCount s; diff --git a/src/effects/Normalize.h b/src/effects/Normalize.h index 84ac09ac0..25192bba9 100644 --- a/src/effects/Normalize.h +++ b/src/effects/Normalize.h @@ -56,10 +56,10 @@ public: private: // EffectNormalize implementation - bool ProcessOne(WaveTrack * t, wxString msg); - virtual void AnalyseTrack(WaveTrack * track, wxString msg); + bool ProcessOne(WaveTrack * t, const wxString &msg); + virtual void AnalyseTrack(WaveTrack * track, const wxString &msg); virtual void AnalyzeData(float *buffer, sampleCount len); - bool AnalyseDC(WaveTrack * track, wxString msg); + bool AnalyseDC(WaveTrack * track, const wxString &msg); virtual void ProcessData(float *buffer, sampleCount len); void OnUpdateUI(wxCommandEvent & evt); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index e5448f6c8..73424c0f9 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2727,7 +2727,7 @@ wxString VSTEffect::b64encode(const void *in, int len) return out; } -int VSTEffect::b64decode(wxString in, void *out) +int VSTEffect::b64decode(const wxString &in, void *out) { int len = in.length(); unsigned char *p = (unsigned char *) out; diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 0f916b238..db6d55025 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -175,7 +175,7 @@ private: // Base64 encoding and decoding static wxString b64encode(const void *in, int len); - static int b64decode(wxString in, void *out); + static int b64decode(const wxString &in, void *out); // Realtime int GetChannelCount(); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 45c074f15..defce70ce 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -114,7 +114,7 @@ BEGIN_EVENT_TABLE(NyquistEffect, wxEvtHandler) wxEVT_COMMAND_CHOICE_SELECTED, NyquistEffect::OnChoice) END_EVENT_TABLE() -NyquistEffect::NyquistEffect(wxString fName) +NyquistEffect::NyquistEffect(const wxString &fName) { mAction = _("Applying Nyquist Effect..."); mInputCmd = wxEmptyString; @@ -1290,7 +1290,7 @@ void NyquistEffect::RedirectOutput() mRedirectOutput = true; } -void NyquistEffect::SetCommand(wxString cmd) +void NyquistEffect::SetCommand(const wxString &cmd) { mExternal = true; @@ -1312,7 +1312,7 @@ void NyquistEffect::Stop() mStop = true; } -wxString NyquistEffect::UnQuote(wxString s) +wxString NyquistEffect::UnQuote(const wxString &s) { wxString out; int len = s.Length(); @@ -1324,7 +1324,7 @@ wxString NyquistEffect::UnQuote(wxString s) return s; } -double NyquistEffect::GetCtrlValue(wxString s) +double NyquistEffect::GetCtrlValue(const wxString &s) { /* For this to work correctly requires that the plug-in header is * parsed on each run so that the correct value for "half-srate" may @@ -1341,10 +1341,10 @@ double NyquistEffect::GetCtrlValue(wxString s) } */ - return Internat::CompatibleToDouble(s);; + return Internat::CompatibleToDouble(s); } -void NyquistEffect::Parse(wxString line) +void NyquistEffect::Parse(const wxString &line) { wxArrayString tokens; @@ -2237,7 +2237,7 @@ END_EVENT_TABLE() NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id, const wxString & title, const wxString & prompt, - wxString message) + const wxString &message) : wxDialog(parent, id, title) { SetName(GetTitle()); diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 7a9b16527..2d2c4db86 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -68,7 +68,7 @@ public: /** @param fName File name of the Nyquist script defining this effect. If * an empty string, then prompt the user for the Nyquist code to interpret. */ - NyquistEffect(wxString fName); + NyquistEffect(const wxString &fName); virtual ~NyquistEffect(); // IdentInterface implementation @@ -106,7 +106,7 @@ public: // For Nyquist Workbench support void RedirectOutput(); - void SetCommand(wxString cmd); + void SetCommand(const wxString &cmd); void Continue(); void Break(); void Stop(); @@ -152,10 +152,10 @@ private: void ParseFile(); bool ParseCommand(const wxString & cmd); bool ParseProgram(wxInputStream & stream); - void Parse(wxString line); + void Parse(const wxString &line); - wxString UnQuote(wxString s); - double GetCtrlValue(wxString s); + wxString UnQuote(const wxString &s); + double GetCtrlValue(const wxString &s); void OnLoad(wxCommandEvent & evt); void OnSave(wxCommandEvent & evt); @@ -248,7 +248,7 @@ public: NyquistOutputDialog(wxWindow * parent, wxWindowID id, const wxString & title, const wxString & prompt, - wxString message); + const wxString &message); private: void OnOk(wxCommandEvent & event); From 923a6ce4af0ed92f56ed49968b72bc3136b48a0c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:17:41 -0500 Subject: [PATCH 7/9] Sweep unnecessary wxString copies: commands --- src/commands/Command.cpp | 8 ++++---- src/commands/Command.h | 12 ++++++------ src/commands/CommandBuilder.cpp | 12 ++++++++---- src/commands/CommandBuilder.h | 4 ++-- src/commands/CommandManager.cpp | 22 +++++++++++----------- src/commands/CommandManager.h | 22 +++++++++++----------- src/commands/CommandTargets.h | 16 ++++++++-------- src/commands/ScreenshotCommand.cpp | 8 ++++---- src/commands/ScreenshotCommand.h | 8 ++++---- src/commands/SetProjectInfoCommand.cpp | 2 +- src/commands/SetProjectInfoCommand.h | 2 +- 11 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index e1aaf190c..d2bbecbbd 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -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); } diff --git a/src/commands/Command.h b/src/commands/Command.h index 8857b819e..a7e6273cc 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -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. diff --git a/src/commands/CommandBuilder.cpp b/src/commands/CommandBuilder.cpp index 07e82d590..6849ec0f2 100644 --- a/src/commands/CommandBuilder.cpp +++ b/src/commands/CommandBuilder.cpp @@ -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); diff --git a/src/commands/CommandBuilder.h b/src/commands/CommandBuilder.h index 06b25bfa8..8c01b9af1 100644 --- a/src/commands/CommandBuilder.h +++ b/src/commands/CommandBuilder.h @@ -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, diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index 626dd32de..2813deb51 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -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]; diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 6337f06cc..3aa8ea370 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -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); diff --git a/src/commands/CommandTargets.h b/src/commands/CommandTargets.h index 561b94a31..402226c2c 100644 --- a/src/commands/CommandTargets.h +++ b/src/commands/CommandTargets.h @@ -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); diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 5410c003f..4122e9275 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -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); diff --git a/src/commands/ScreenshotCommand.h b/src/commands/ScreenshotCommand.h index f49d97388..d827ab7ed 100644 --- a/src/commands/ScreenshotCommand.h +++ b/src/commands/ScreenshotCommand.h @@ -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); diff --git a/src/commands/SetProjectInfoCommand.cpp b/src/commands/SetProjectInfoCommand.cpp index 1724cacba..b95132ca5 100644 --- a/src/commands/SetProjectInfoCommand.cpp +++ b/src/commands/SetProjectInfoCommand.cpp @@ -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); diff --git a/src/commands/SetProjectInfoCommand.h b/src/commands/SetProjectInfoCommand.h index 97444048e..2efc815e3 100644 --- a/src/commands/SetProjectInfoCommand.h +++ b/src/commands/SetProjectInfoCommand.h @@ -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; From 6597575f6ae7d4ca491781c64d2cb62cdad0f961 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:18:00 -0500 Subject: [PATCH 8/9] Sweep unnecessary wxString copies: blockfile --- src/blockfile/LegacyAliasBlockFile.cpp | 2 +- src/blockfile/LegacyAliasBlockFile.h | 2 +- src/blockfile/LegacyBlockFile.cpp | 2 +- src/blockfile/LegacyBlockFile.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/blockfile/LegacyAliasBlockFile.cpp b/src/blockfile/LegacyAliasBlockFile.cpp index 53eae0206..55181575d 100644 --- a/src/blockfile/LegacyAliasBlockFile.cpp +++ b/src/blockfile/LegacyAliasBlockFile.cpp @@ -81,7 +81,7 @@ void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile) // BuildFromXML methods should always return a BlockFile, not NULL, // even if the result is flawed (e.g., refers to nonexistent file), // as testing will be done in DirManager::ProjectFSCK(). -BlockFile *LegacyAliasBlockFile::BuildFromXML(wxString projDir, const wxChar **attrs) +BlockFile *LegacyAliasBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs) { wxFileName summaryFileName; wxFileName aliasFileName; diff --git a/src/blockfile/LegacyAliasBlockFile.h b/src/blockfile/LegacyAliasBlockFile.h index a38e3cbcc..8b8345926 100644 --- a/src/blockfile/LegacyAliasBlockFile.h +++ b/src/blockfile/LegacyAliasBlockFile.h @@ -35,7 +35,7 @@ class LegacyAliasBlockFile : public PCMAliasBlockFile virtual BlockFile *Copy(wxFileName fileName); virtual void Recover(); - static BlockFile *BuildFromXML(wxString projDir, const wxChar **attrs); + static BlockFile *BuildFromXML(const wxString &projDir, const wxChar **attrs); }; #endif diff --git a/src/blockfile/LegacyBlockFile.cpp b/src/blockfile/LegacyBlockFile.cpp index 2bfbc497d..dce1abff7 100644 --- a/src/blockfile/LegacyBlockFile.cpp +++ b/src/blockfile/LegacyBlockFile.cpp @@ -284,7 +284,7 @@ void LegacyBlockFile::SaveXML(XMLWriter &xmlFile) // even if the result is flawed (e.g., refers to nonexistent file), // as testing will be done in DirManager::ProjectFSCK(). /// static -BlockFile *LegacyBlockFile::BuildFromXML(wxString projDir, const wxChar **attrs, +BlockFile *LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar **attrs, sampleCount len, sampleFormat format) { wxFileName fileName; diff --git a/src/blockfile/LegacyBlockFile.h b/src/blockfile/LegacyBlockFile.h index d71fd96fb..b59e63816 100644 --- a/src/blockfile/LegacyBlockFile.h +++ b/src/blockfile/LegacyBlockFile.h @@ -60,7 +60,7 @@ class LegacyBlockFile : public BlockFile { virtual wxLongLong GetSpaceUsage(); virtual void Recover(); - static BlockFile *BuildFromXML(wxString dir, const wxChar **attrs, + static BlockFile *BuildFromXML(const wxString &dir, const wxChar **attrs, sampleCount len, sampleFormat format); From 9bf098c7d94cf9fa4b1c49da4132cc18f6b96f74 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 22 Feb 2016 21:18:11 -0500 Subject: [PATCH 9/9] Sweep unnecessary wxString copies: rest --- src/AboutDialog.cpp | 2 +- src/AboutDialog.h | 2 +- src/AudacityApp.cpp | 13 +++++++------ src/AudacityApp.h | 8 ++++---- src/AudioIO.cpp | 8 +++++--- src/AudioIO.h | 6 +++--- src/BatchCommands.cpp | 2 +- src/BatchCommands.h | 2 +- src/DirManager.cpp | 18 +++++++++--------- src/DirManager.h | 20 ++++++++++---------- src/FFmpeg.cpp | 2 +- src/FFmpeg.h | 2 +- src/LabelDialog.cpp | 2 +- src/LabelDialog.h | 2 +- src/Lyrics.cpp | 2 +- src/Lyrics.h | 2 +- src/MixerBoard.cpp | 2 +- src/MixerBoard.h | 2 +- src/ModuleManager.cpp | 2 +- src/ModuleManager.h | 2 +- src/NoteTrack.cpp | 4 ++-- src/NoteTrack.h | 4 ++-- src/PluginManager.cpp | 2 +- src/PluginManager.h | 2 +- src/Printing.cpp | 2 +- src/Printing.h | 2 +- src/Project.cpp | 18 ++++++++++-------- src/Project.h | 18 +++++++++--------- src/Sequence.cpp | 4 ++-- src/Sequence.h | 4 ++-- src/Tags.cpp | 4 ++-- src/Tags.h | 4 ++-- src/TimeDialog.cpp | 2 +- src/TimeDialog.h | 2 +- src/Track.h | 4 ++-- src/TrackPanel.cpp | 2 +- src/TrackPanel.h | 2 +- src/TrackPanelListener.h | 4 ++-- src/UndoManager.cpp | 6 +++--- src/UndoManager.h | 4 ++-- src/WaveClip.cpp | 4 ++-- src/WaveClip.h | 4 ++-- src/WaveTrack.cpp | 4 ++-- src/WaveTrack.h | 4 ++-- 44 files changed, 108 insertions(+), 103 deletions(-) diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 9a52c40d9..7031d728e 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -892,7 +892,7 @@ wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role) * * Used when creating the build information tab to show if each optional * library is enabled or not, and what it does */ -void AboutDialog::AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, wxString status) +void AboutDialog::AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, const wxString &status) { *htmlstring += wxT(""); *htmlstring += libname; diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 06aeb30a3..20b2cb464 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -76,7 +76,7 @@ class AboutDialog:public wxDialog { void AddCredit(wxString &&description, Role role); wxString GetCreditsByRole(AboutDialog::Role role); - void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, wxString status); + void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, const wxString &status); void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc); }; diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 337fd79ae..e960e27c5 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -769,7 +769,7 @@ END_EVENT_TABLE() // TODO: Would be nice to make this handle not opening a file with more panache. // - Inform the user if DefaultOpenPath not set. // - Switch focus to correct instance of project window, if already open. -bool AudacityApp::MRUOpen(wxString fullPathStr) { +bool AudacityApp::MRUOpen(const wxString &fullPathStr) { // Most of the checks below are copied from AudacityProject::OpenFiles. // - some rationalisation might be possible. @@ -1630,7 +1630,7 @@ bool AudacityApp::InitTempDir() // // Use "dir" for creating lockfiles (on OS X and Unix). -bool AudacityApp::CreateSingleInstanceChecker(wxString dir) +bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir) { wxString name = wxString::Format(wxT("audacity-lock-%s"), wxGetUserId().c_str()); mChecker = new wxSingleInstanceChecker(); @@ -1868,12 +1868,12 @@ wxCmdLineParser *AudacityApp::ParseCommandLine() } // static -void AudacityApp::AddUniquePathToPathList(wxString path, +void AudacityApp::AddUniquePathToPathList(const wxString &pathArg, wxArrayString &pathList) { - wxFileName pathNorm = path; + wxFileName pathNorm = pathArg; pathNorm.Normalize(); - path = pathNorm.GetFullPath(); + wxString path = pathNorm.GetFullPath(); for(unsigned int i=0; isecond == b; } -bool DirManager::ContainsBlockFile(wxString filepath) const +bool DirManager::ContainsBlockFile(const wxString &filepath) const { // check what the hash returns in case the blockfile is from a different project BlockHash::const_iterator it = mBlockFileHash.find(filepath); diff --git a/src/DirManager.h b/src/DirManager.h index 9ba6fbf8a..986322590 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -43,7 +43,7 @@ class DirManager: public XMLTagHandler { // MM: Only called by Deref() when refcount reaches zero. virtual ~DirManager(); - static void SetTempDir(wxString _temp) { globaltemp = _temp; } + static void SetTempDir(const wxString &_temp) { globaltemp = _temp; } // MM: Ref count mechanism for the DirManager itself void Ref(); @@ -64,19 +64,19 @@ class DirManager: public XMLTagHandler { sampleFormat format, bool allowDeferredWrite = false); - BlockFile *NewAliasBlockFile( wxString aliasedFile, sampleCount aliasStart, + BlockFile *NewAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, sampleCount aliasLen, int aliasChannel); - BlockFile *NewODAliasBlockFile( wxString aliasedFile, sampleCount aliasStart, + BlockFile *NewODAliasBlockFile( const wxString &aliasedFile, sampleCount aliasStart, sampleCount aliasLen, int aliasChannel); - BlockFile *NewODDecodeBlockFile( wxString aliasedFile, sampleCount aliasStart, + BlockFile *NewODDecodeBlockFile( const wxString &aliasedFile, sampleCount aliasStart, sampleCount aliasLen, int aliasChannel, int decodeType); /// Returns true if the blockfile pointed to by b is contained by the DirManager bool ContainsBlockFile(BlockFile *b) const; /// Check for existing using filename using complete filename - bool ContainsBlockFile(wxString filepath) const; + bool ContainsBlockFile(const wxString &filepath) const; // Adds one to the reference count of the block file, // UNLESS it is "locked", then it makes a NEW copy of @@ -116,7 +116,7 @@ class DirManager: public XMLTagHandler { bool HandleXMLTag(const wxChar *tag, const wxChar **attrs); XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) { return NULL; } void WriteXML(XMLWriter & WXUNUSED(xmlFile)) { wxASSERT(false); } // This class only reads tags. - bool AssignFile(wxFileName &filename,wxString value,bool check); + bool AssignFile(wxFileName &filename, const wxString &value, bool check); // Clean the temp dir. Note that now where we have auto recovery the temp // dir is not cleaned at start up anymore. But it is cleaned when the @@ -154,7 +154,7 @@ class DirManager: public XMLTagHandler { wxString GetDataFilesDir() const; // This should only be used by the auto save functionality - void SetLocalTempDir(wxString path); + void SetLocalTempDir(const wxString &path); // Do not DELETE any temporary files on exit. This is only called if // auto recovery is cancelled and should be retried later @@ -169,7 +169,7 @@ class DirManager: public XMLTagHandler { private: wxFileName MakeBlockFileName(); - wxFileName MakeBlockFilePath(wxString value); + wxFileName MakeBlockFilePath(const wxString &value); bool MoveOrCopyToNewProjectDirectory(BlockFile *f, bool copy); @@ -181,8 +181,8 @@ class DirManager: public XMLTagHandler { DirHash dirMidPool; // available two-level dirs DirHash dirMidFull; // full two-level dirs - void BalanceInfoDel(wxString); - void BalanceInfoAdd(wxString); + void BalanceInfoDel(const wxString&); + void BalanceInfoAdd(const wxString&); void BalanceFileAdd(int); int BalanceMidAdd(int, int); diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 741dd53e2..21ca9e5fe 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -715,7 +715,7 @@ bool FFmpegLibs::ValidLibsLoaded() return mLibsLoaded; } -bool FFmpegLibs::InitLibs(wxString libpath_format, bool WXUNUSED(showerr)) +bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr)) { #if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) FreeLibs(); diff --git a/src/FFmpeg.h b/src/FFmpeg.h index aef40ae8b..92c690bc4 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -256,7 +256,7 @@ public: ///\param showerr - controls whether or not to show an error dialog if libraries cannot be loaded ///\return true if initialization completed without errors, false otherwise /// do not call (it is called by FindLibs automatically) - bool InitLibs(wxString libpath_codec, bool showerr); + bool InitLibs(const wxString &libpath_codec, bool showerr); ///! Frees (unloads) loaded libraries void FreeLibs(); diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 8689ae7a8..5463a0e19 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -358,7 +358,7 @@ bool LabelDialog::Validate() return true; } -wxString LabelDialog::TrackName(int & index, wxString dflt) +wxString LabelDialog::TrackName(int & index, const wxString &dflt) { // Generate a NEW track name if the passed index is out of range if (index < 1 || index >= (int)mTrackNames.GetCount()) { diff --git a/src/LabelDialog.h b/src/LabelDialog.h index 46cdb13f6..05010e4e5 100644 --- a/src/LabelDialog.h +++ b/src/LabelDialog.h @@ -52,7 +52,7 @@ class LabelDialog:public wxDialog void FindAllLabels(); void AddLabels(LabelTrack *t); void FindInitialRow(); - wxString TrackName(int & index, wxString dflt = _("Label Track")); + wxString TrackName(int & index, const wxString &dflt = _("Label Track")); void OnUpdate(wxCommandEvent &event); void OnInsert(wxCommandEvent &event); diff --git a/src/Lyrics.cpp b/src/Lyrics.cpp index 90ae34887..3c465e96b 100644 --- a/src/Lyrics.cpp +++ b/src/Lyrics.cpp @@ -143,7 +143,7 @@ void Lyrics::AddLabels(const LabelTrack *pLT) mHighlightTextCtrl->AppendText(highlightText); } -void Lyrics::Add(double t, wxString syllable, wxString &highlightText) +void Lyrics::Add(double t, const wxString &syllable, wxString &highlightText) { int i = mSyllables.GetCount(); diff --git a/src/Lyrics.h b/src/Lyrics.h index 4ca9bd7f8..26c09503d 100644 --- a/src/Lyrics.h +++ b/src/Lyrics.h @@ -105,7 +105,7 @@ class Lyrics : public wxPanel void HandleLayout(); private: - void Add(double t, wxString syllable, wxString &highlightText); + void Add(double t, const wxString &syllable, wxString &highlightText); unsigned int GetDefaultFontSize() const; // Depends on mLyricsStyle. Call only after mLyricsStyle is set. diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index a4eaf1f19..22c1eff28 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -53,7 +53,7 @@ END_EVENT_TABLE() MixerTrackSlider::MixerTrackSlider(wxWindow * parent, wxWindowID id, - wxString name, + const wxString &name, const wxPoint & pos, const wxSize & size, int style /*= FRAC_SLIDER*/, diff --git a/src/MixerBoard.h b/src/MixerBoard.h index d87d23a6a..4ff923cba 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -36,7 +36,7 @@ class MixerTrackSlider : public ASlider public: MixerTrackSlider(wxWindow * parent, wxWindowID id, - wxString name, + const wxString &name, const wxPoint & pos, const wxSize & size, int style = FRAC_SLIDER, diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index 477bc8e07..7e66d21a5 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -168,7 +168,7 @@ int Module::Dispatch(ModuleDispatchTypes type) return 0; } -void * Module::GetSymbol(wxString name) +void * Module::GetSymbol(const wxString &name) { return mLib->GetSymbol(name); } diff --git a/src/ModuleManager.h b/src/ModuleManager.h index 18dab66c1..d26499381 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -53,7 +53,7 @@ public: bool Load(); void Unload(); int Dispatch(ModuleDispatchTypes type); - void * GetSymbol(wxString name); + void * GetSymbol(const wxString &name); private: wxString mName; diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 795126871..44fcaec8f 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -724,7 +724,7 @@ Alg_seq_ptr NoteTrack::MakeExportableSeq() } -bool NoteTrack::ExportMIDI(wxString f) +bool NoteTrack::ExportMIDI(const wxString &f) { Alg_seq_ptr seq = MakeExportableSeq(); bool rslt = seq->smf_write(f.mb_str()); @@ -732,7 +732,7 @@ bool NoteTrack::ExportMIDI(wxString f) return rslt; } -bool NoteTrack::ExportAllegro(wxString f) +bool NoteTrack::ExportAllegro(const wxString &f) { double offset = GetOffset(); bool in_seconds; diff --git a/src/NoteTrack.h b/src/NoteTrack.h index 90f9b7e77..d77c74d08 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -78,8 +78,8 @@ class AUDACITY_DLL_API NoteTrack:public Track { int GetVisibleChannels(); Alg_seq_ptr MakeExportableSeq(); - bool ExportMIDI(wxString f); - bool ExportAllegro(wxString f); + bool ExportMIDI(const wxString &f); + bool ExportAllegro(const wxString &f); /* REQUIRES PORTMIDI */ // int GetLastMidiPosition() const { return mLastMidiPosition; } diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 1c4b38cd2..ceb85ee8a 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -2896,7 +2896,7 @@ wxString PluginManager::b64encode(const void *in, int len) return out; } -int PluginManager::b64decode(wxString in, void *out) +int PluginManager::b64decode(const wxString &in, void *out) { int len = in.length(); unsigned char *p = (unsigned char *) out; diff --git a/src/PluginManager.h b/src/PluginManager.h index 5b7b61f83..a79b3d85c 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -301,7 +301,7 @@ private: // case, we use base64 encoding. wxString ConvertID(const PluginID & ID); wxString b64encode(const void *in, int len); - int b64decode(wxString in, void *out); + int b64decode(const wxString &in, void *out); private: static PluginManager *mInstance; diff --git a/src/Printing.cpp b/src/Printing.cpp index 5f382828d..2b4155d5a 100644 --- a/src/Printing.cpp +++ b/src/Printing.cpp @@ -153,7 +153,7 @@ void HandlePageSetup(wxWindow *parent) (*gPageSetupData) = pageSetupDialog.GetPageSetupData(); } -void HandlePrint(wxWindow *parent, wxString name, TrackList *tracks) +void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks) { if (gPageSetupData == NULL) gPageSetupData = new wxPageSetupDialogData(); diff --git a/src/Printing.h b/src/Printing.h index ddc1805fe..e481ca67c 100644 --- a/src/Printing.h +++ b/src/Printing.h @@ -18,7 +18,7 @@ class wxWindow; class TrackList; void HandlePageSetup(wxWindow *parent); -void HandlePrint(wxWindow *parent, wxString name, TrackList *tracks); +void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks); #endif // __AUDACITY_PRINTING__ diff --git a/src/Project.cpp b/src/Project.cpp index 8fb76ad31..211b1afdd 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2397,7 +2397,7 @@ void AudacityProject::OnOpenAudioFile(wxCommandEvent & event) } // static method, can be called outside of a project -wxArrayString AudacityProject::ShowOpenDialog(wxString extraformat, wxString extrafilter) +wxArrayString AudacityProject::ShowOpenDialog(const wxString &extraformat, const wxString &extrafilter) { FormatList l; wxString filter; ///< List of file format names and extensions, separated @@ -2605,8 +2605,10 @@ bool AudacityProject::WarnOfLegacyFile( ) // FIXME? This should return a result that is checked. // See comment in AudacityApp::MRUOpen(). -void AudacityProject::OpenFile(wxString fileName, bool addtohistory) +void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory) { + wxString fileName(fileNameArg); + // On Win32, we may be given a short (DOS-compatible) file name on rare // occassions (e.g. stuff like "C:\PROGRA~1\AUDACI~1\PROJEC~1.AUP"). We // convert these to long file name first. @@ -3704,7 +3706,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ , #endif -void AudacityProject::AddImportedTracks(wxString fileName, +void AudacityProject::AddImportedTracks(const wxString &fileName, Track **newTracks, int numTracks) { SelectNone(); @@ -3784,7 +3786,7 @@ void AudacityProject::AddImportedTracks(wxString fileName, } // If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks. -bool AudacityProject::Import(wxString fileName, WaveTrackArray* pTrackArray /*= NULL*/) +bool AudacityProject::Import(const wxString &fileName, WaveTrackArray* pTrackArray /*= NULL*/) { Track **newTracks; int numTracks; @@ -3994,8 +3996,8 @@ void AudacityProject::InitialState() this->UpdateMixerBoard(); } -void AudacityProject::PushState(wxString desc, - wxString shortDesc, +void AudacityProject::PushState(const wxString &desc, + const wxString &shortDesc, int flags ) { mUndoManager.PushState(mTracks, mViewInfo.selectedRegion, @@ -4627,7 +4629,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action ) // TrackPanel callback method -void AudacityProject::TP_DisplayStatusMessage(wxString msg) +void AudacityProject::TP_DisplayStatusMessage(const wxString &msg) { mStatusBar->SetStatusText(msg, mainStatusBarField); mLastStatusUpdateTime = ::wxGetUTCTime(); @@ -4696,7 +4698,7 @@ void AudacityProject::RefreshTPTrack(Track* pTrk, bool refreshbacking /*= true*/ // TrackPanel callback method -void AudacityProject::TP_PushState(wxString desc, wxString shortDesc, +void AudacityProject::TP_PushState(const wxString &desc, const wxString &shortDesc, int flags) { PushState(desc, shortDesc, flags); diff --git a/src/Project.h b/src/Project.h index e5dc7b830..81397fad4 100644 --- a/src/Project.h +++ b/src/Project.h @@ -219,17 +219,17 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame, * @return Array of file paths which the user selected to open (multiple * selections allowed). */ - static wxArrayString ShowOpenDialog(wxString extraformat = wxEmptyString, - wxString extrafilter = wxEmptyString); + static wxArrayString ShowOpenDialog(const wxString &extraformat = wxEmptyString, + const wxString &extrafilter = wxEmptyString); static bool IsAlreadyOpen(const wxString & projPathName); static void OpenFiles(AudacityProject *proj); - void OpenFile(wxString fileName, bool addtohistory = true); + void OpenFile(const wxString &fileName, bool addtohistory = true); bool WarnOfLegacyFile( ); // If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks. - bool Import(wxString fileName, WaveTrackArray *pTrackArray = NULL); + bool Import(const wxString &fileName, WaveTrackArray *pTrackArray = NULL); - void AddImportedTracks(wxString fileName, + void AddImportedTracks(const wxString &fileName, Track **newTracks, int numTracks); void LockAllBlocks(); void UnlockAllBlocks(); @@ -394,12 +394,12 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame, // TrackPanel callback methods, overrides of TrackPanelListener virtual void TP_DisplaySelection(); - virtual void TP_DisplayStatusMessage(wxString msg); + virtual void TP_DisplayStatusMessage(const wxString &msg) override; virtual ToolsToolBar * TP_GetToolsToolBar(); - virtual void TP_PushState(wxString longDesc, wxString shortDesc, - int flags); + virtual void TP_PushState(const wxString &longDesc, const wxString &shortDesc, + int flags) override; virtual void TP_ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after // a crash, as it can take many seconds for large (eg. 10 track-hours) projects virtual void TP_RedrawScrollbars(); @@ -486,7 +486,7 @@ public: static void AllProjectsDeleteLock(); static void AllProjectsDeleteUnlock(); - void PushState(wxString desc, wxString shortDesc, + void PushState(const wxString &desc, const wxString &shortDesc, int flags = PUSH_AUTOSAVE); void RollbackState(); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 6765a66b5..3a8ba1afd 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -708,7 +708,7 @@ bool Sequence::InsertSilence(sampleCount s0, sampleCount len) return bResult && ConsistencyCheck(wxT("InsertSilence")); } -bool Sequence::AppendAlias(wxString fullPath, +bool Sequence::AppendAlias(const wxString &fullPath, sampleCount start, sampleCount len, int channel, bool useOD) { @@ -728,7 +728,7 @@ bool Sequence::AppendAlias(wxString fullPath, return true; } -bool Sequence::AppendCoded(wxString fName, sampleCount start, +bool Sequence::AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType) { // Quick check to make sure that it doesn't overflow diff --git a/src/Sequence.h b/src/Sequence.h index 26238e12d..f18ff857e 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -109,11 +109,11 @@ class Sequence: public XMLTagHandler { bool Append(samplePtr buffer, sampleFormat format, sampleCount len, XMLWriter* blockFileLog=NULL); bool Delete(sampleCount start, sampleCount len); - bool AppendAlias(wxString fullPath, + bool AppendAlias(const wxString &fullPath, sampleCount start, sampleCount len, int channel, bool useOD); - bool AppendCoded(wxString fName, sampleCount start, + bool AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. diff --git a/src/Tags.cpp b/src/Tags.cpp index deeb6c0d4..591d7c4c6 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -521,7 +521,7 @@ void Tags::WriteXML(XMLWriter &xmlFile) xmlFile.EndTag(wxT("tags")); } -bool Tags::ShowEditDialog(wxWindow *parent, wxString title, bool force) +bool Tags::ShowEditDialog(wxWindow *parent, const wxString &title, bool force) { if (force) { TagsEditor dlg(parent, title, this, mEditTitle, mEditTrackNumber); @@ -639,7 +639,7 @@ BEGIN_EVENT_TABLE(TagsEditor, wxDialog) END_EVENT_TABLE() TagsEditor::TagsEditor(wxWindow * parent, - wxString title, + const wxString &title, Tags * tags, bool editTitle, bool editTrack) diff --git a/src/Tags.h b/src/Tags.h index 873a60470..7edb1b2e2 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -78,7 +78,7 @@ class AUDACITY_DLL_API Tags: public XMLTagHandler { Tags & operator= (const Tags & src ); - bool ShowEditDialog(wxWindow *parent, wxString title, bool force = false); + bool ShowEditDialog(wxWindow *parent, const wxString &title, bool force = false); virtual bool HandleXMLTag(const wxChar *tag, const wxChar **attrs); virtual XMLTagHandler *HandleXMLChild(const wxChar *tag); @@ -126,7 +126,7 @@ class TagsEditor: public wxDialog public: // constructors and destructors TagsEditor(wxWindow * parent, - wxString title, + const wxString &title, Tags * tags, bool editTitle, bool editTrackNumber); diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index 1298fb970..48de799bd 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -103,7 +103,7 @@ const double TimeDialog::GetTimeValue() return mTime; } -void TimeDialog::SetFormatString(wxString formatString) +void TimeDialog::SetFormatString(const wxString &formatString) { mFormat = formatString; TransferDataToWindow(); diff --git a/src/TimeDialog.h b/src/TimeDialog.h index 99f6cfb09..f464e0bde 100644 --- a/src/TimeDialog.h +++ b/src/TimeDialog.h @@ -30,7 +30,7 @@ class TimeDialog:public wxDialog double time, const wxString &prompt = _("Duration")); - void SetFormatString(wxString formatString); + void SetFormatString(const wxString &formatString); void SetSampleRate(double sampleRate); void SetTimeValue(double newTime); const double GetTimeValue(); diff --git a/src/Track.h b/src/Track.h index 9098b4fc8..64e4ff4f4 100644 --- a/src/Track.h +++ b/src/Track.h @@ -153,9 +153,9 @@ class AUDACITY_DLL_API Track: public XMLTagHandler virtual void Merge(const Track &orig); wxString GetName() const { return mName; } - void SetName( wxString n ) { mName = n; } + void SetName( const wxString &n ) { mName = n; } wxString GetDefaultName() const { return mDefaultName; } - void SetDefaultName( wxString n ) { mDefaultName = n; } + void SetDefaultName( const wxString &n ) { mDefaultName = n; } bool GetSelected() const { return mSelected; } bool GetMute () const { return mMute; } diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 91ca75e21..3d7e2edbb 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1491,7 +1491,7 @@ void TrackPanel::OnPaint(wxPaintEvent & /* event */) /// Makes our Parent (well, whoever is listening to us) push their state. /// this causes application state to be preserved on a stack for undo ops. -void TrackPanel::MakeParentPushState(wxString desc, wxString shortDesc, +void TrackPanel::MakeParentPushState(const wxString &desc, const wxString &shortDesc, int flags) { mListener->TP_PushState(desc, shortDesc, flags); diff --git a/src/TrackPanel.h b/src/TrackPanel.h index df8547d3d..dbe95eac2 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -457,7 +457,7 @@ protected: virtual void MakeParentRedrawScrollbars(); // AS: Pushing the state preserves state for Undo operations. - virtual void MakeParentPushState(wxString desc, wxString shortDesc, + virtual void MakeParentPushState(const wxString &desc, const wxString &shortDesc, int flags = PUSH_AUTOSAVE); virtual void MakeParentModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after // a crash, as it can take many seconds for large (eg. 10 track-hours) projects diff --git a/src/TrackPanelListener.h b/src/TrackPanelListener.h index fd147d720..15385957e 100644 --- a/src/TrackPanelListener.h +++ b/src/TrackPanelListener.h @@ -21,11 +21,11 @@ class AUDACITY_DLL_API TrackPanelListener { virtual ~TrackPanelListener(){}; virtual void TP_DisplaySelection() = 0; - virtual void TP_DisplayStatusMessage(wxString msg) = 0; + virtual void TP_DisplayStatusMessage(const wxString &msg) = 0; virtual ToolsToolBar * TP_GetToolsToolBar() = 0; - virtual void TP_PushState(wxString shortDesc, wxString longDesc, + virtual void TP_PushState(const wxString &shortDesc, const wxString &longDesc, int flags = PUSH_AUTOSAVE) = 0; virtual void TP_ModifyState(bool bWantsAutoSave) = 0; // if true, writes auto-save file. Should set only if you really want the state change restored after // a crash, as it can take many seconds for large (eg. 10 track-hours) projects diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp index 36a68e33c..30524974e 100644 --- a/src/UndoManager.cpp +++ b/src/UndoManager.cpp @@ -128,7 +128,7 @@ void UndoManager::GetShortDescription(unsigned int n, wxString *desc) *desc = stack[n]->shortDescription; } -void UndoManager::SetLongDescription(unsigned int n, wxString desc) +void UndoManager::SetLongDescription(unsigned int n, const wxString &desc) { n -= 1; @@ -212,8 +212,8 @@ void UndoManager::ModifyState(TrackList * l, void UndoManager::PushState(TrackList * l, const SelectedRegion &selectedRegion, - wxString longDescription, - wxString shortDescription, + const wxString &longDescription, + const wxString &shortDescription, int flags) { unsigned int i; diff --git a/src/UndoManager.h b/src/UndoManager.h index d28bd9c04..f42b8e2f4 100644 --- a/src/UndoManager.h +++ b/src/UndoManager.h @@ -82,7 +82,7 @@ class AUDACITY_DLL_API UndoManager { void PushState(TrackList * l, const SelectedRegion &selectedRegion, - wxString longDescription, wxString shortDescription, + const wxString &longDescription, const wxString &shortDescription, int flags = PUSH_AUTOSAVE); void ModifyState(TrackList * l, const SelectedRegion &selectedRegion); @@ -94,7 +94,7 @@ class AUDACITY_DLL_API UndoManager { void GetShortDescription(unsigned int n, wxString *desc); wxLongLong_t GetLongDescription(unsigned int n, wxString *desc, wxString *size); - void SetLongDescription(unsigned int n, wxString desc); + void SetLongDescription(unsigned int n, const wxString &desc); TrackList *SetStateTo(unsigned int n, SelectedRegion *selectedRegion); TrackList *Undo(SelectedRegion *selectedRegion); diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 6e0b17c0b..fa35e4a2f 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -1297,7 +1297,7 @@ bool WaveClip::Append(samplePtr buffer, sampleFormat format, return true; } -bool WaveClip::AppendAlias(wxString fName, sampleCount start, +bool WaveClip::AppendAlias(const wxString &fName, sampleCount start, sampleCount len, int channel,bool useOD) { bool result = mSequence->AppendAlias(fName, start, len, channel,useOD); @@ -1309,7 +1309,7 @@ bool WaveClip::AppendAlias(wxString fName, sampleCount start, return result; } -bool WaveClip::AppendCoded(wxString fName, sampleCount start, +bool WaveClip::AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType) { bool result = mSequence->AppendCoded(fName, start, len, channel, decodeType); diff --git a/src/WaveClip.h b/src/WaveClip.h index 507634c40..5ddbfb961 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -309,10 +309,10 @@ public: /// Flush must be called after last Append bool Flush(); - bool AppendAlias(wxString fName, sampleCount start, + bool AppendAlias(const wxString &fName, sampleCount start, sampleCount len, int channel,bool useOD); - bool AppendCoded(wxString fName, sampleCount start, + bool AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType); /// This name is consistent with WaveTrack::Clear. It performs a "Cut" diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 60e97d581..0a78fd175 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1566,14 +1566,14 @@ bool WaveTrack::Append(samplePtr buffer, sampleFormat format, blockFileLog); } -bool WaveTrack::AppendAlias(wxString fName, sampleCount start, +bool WaveTrack::AppendAlias(const wxString &fName, sampleCount start, sampleCount len, int channel,bool useOD) { return RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD); } -bool WaveTrack::AppendCoded(wxString fName, sampleCount start, +bool WaveTrack::AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType) { return RightmostOrNewClip()->AppendCoded(fName, start, len, channel, decodeType); diff --git a/src/WaveTrack.h b/src/WaveTrack.h index 1a51bdb8f..0c6476e30 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -202,14 +202,14 @@ class AUDACITY_DLL_API WaveTrack : public Track { /// Flush must be called after last Append bool Flush(); - bool AppendAlias(wxString fName, sampleCount start, + bool AppendAlias(const wxString &fName, sampleCount start, sampleCount len, int channel,bool useOD); ///for use with On-Demand decoding of compressed files. ///decodeType should be an enum from ODDecodeTask that specifies what ///Type of encoded file this is, such as eODFLAC //vvv Why not use the ODTypeEnum typedef to enforce that for the parameter? - bool AppendCoded(wxString fName, sampleCount start, + bool AppendCoded(const wxString &fName, sampleCount start, sampleCount len, int channel, int decodeType); ///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc.