diff --git a/src/common/DebugHelpers.cpp b/src/common/DebugHelpers.cpp index 1683070350d..1dd49668e24 100644 --- a/src/common/DebugHelpers.cpp +++ b/src/common/DebugHelpers.cpp @@ -80,7 +80,7 @@ void Surge::Debug::stackTraceToStdout(int depth) } static std::atomic lcdepth(0); -Surge::Debug::LifeCycleToConsole::LifeCycleToConsole(std::string st) : s(st) +Surge::Debug::LifeCycleToConsole::LifeCycleToConsole(const std::string &st) : s(st) { lcdepth++; for (int i = 0; i < lcdepth; ++i) diff --git a/src/common/DebugHelpers.h b/src/common/DebugHelpers.h index fbcabcadd19..7aca7824820 100644 --- a/src/common/DebugHelpers.h +++ b/src/common/DebugHelpers.h @@ -30,7 +30,7 @@ void stackTraceToStdout(int depth = -1); // no-op on Windows; shows stack trace struct LifeCycleToConsole { // simple class which printfs in ctor and dtor - LifeCycleToConsole(std::string s); + LifeCycleToConsole(const std::string &s); ~LifeCycleToConsole(); std::string s; }; diff --git a/src/common/FilterConfiguration.h b/src/common/FilterConfiguration.h index b764bbc38fb..52cb423ea72 100644 --- a/src/common/FilterConfiguration.h +++ b/src/common/FilterConfiguration.h @@ -325,7 +325,7 @@ struct FilterSelectorMapper : public ParameterDiscreteIndexRemapper { std::vector> mapping; std::unordered_map inverseMapping; - void p(int i, std::string s) { mapping.push_back(std::make_pair(i, s)); } + void p(int i, const std::string &s) { mapping.push_back(std::make_pair(i, s)); } FilterSelectorMapper() { p(fut_none, ""); @@ -475,7 +475,7 @@ struct WaveShaperSelectorMapper : public ParameterDiscreteIndexRemapper { std::vector> mapping; std::unordered_map inverseMapping; - void p(int i, std::string s) { mapping.emplace_back(i, s); } + void p(int i, const std::string &s) { mapping.emplace_back(i, s); } WaveShaperSelectorMapper() { // Obviously improve this diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index 1efe30115dd..a2ff0d93c87 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -3758,9 +3758,12 @@ bool Parameter::can_setvalue_from_string() return false; } -bool Parameter::set_value_from_string(std::string s) { return set_value_from_string_onto(s, val); } +bool Parameter::set_value_from_string(const std::string &s) +{ + return set_value_from_string_onto(s, val); +} -bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) +bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis) { const char *c = s.c_str(); @@ -3811,13 +3814,14 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) int neg = 1; // convert string to lowercase - std::for_each(s.begin(), s.end(), + auto lowerS = s; + std::for_each(lowerS.begin(), lowerS.end(), [](char &c) { c = ::tolower(static_cast(c)); }); // find the unmodified note for (int i = 0; i < 7; i++) { - n = s.find(notes[i]); + n = lowerS.find(notes[i]); if (n != std::string::npos) { val = pitches[i]; @@ -3827,31 +3831,32 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) // check if the following character is sharp or flat, adjust val if so n++; - if ((m = s.find("#", n, 1)) != std::string::npos) + if ((m = lowerS.find("#", n, 1)) != std::string::npos) { val += 1; n++; } - else if ((m = s.find("b", n, 1)) != std::string::npos) + else if ((m = lowerS.find("b", n, 1)) != std::string::npos) { val -= 1; n++; } // if neither note modifiers are found, check for minus - if ((m = s.find("-", n, 1)) != std::string::npos) + if ((m = lowerS.find("-", n, 1)) != std::string::npos) { neg = -1; n++; } // finally, octave number - s = s.substr(n, s.length() - n); // trim the fat to the left of current char + auto q = lowerS.substr(n, lowerS.length() - + n); // trim the fat to the left of current char int oct; try { - oct = std::stoi(s); + oct = std::stoi(q); } catch (std::invalid_argument const &) { @@ -3873,7 +3878,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) if (ni >= val_min.i && ni <= val_max.i) { - onto.i = ni; + ontoThis.i = ni; return true; } @@ -3895,7 +3900,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) float f; if (ef->stringToValue(this, c, f)) { - onto.f = limit_range(f, val_min.f, val_max.f); + ontoThis.f = limit_range(f, val_min.f, val_max.f); return true; } } @@ -3921,7 +3926,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) return false; } - onto.f = res; + ontoThis.f = res; return true; break; @@ -3980,7 +3985,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) { return false; } - onto.f = res; + ontoThis.f = res; return true; break; } @@ -4004,7 +4009,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) return false; } - onto.f = nv; + ontoThis.f = nv; return true; } break; @@ -4018,7 +4023,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) { return false; } - onto.f = nv; + ontoThis.f = nv; return true; } break; @@ -4029,7 +4034,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) float uv = std::atof(c) / 440.f; float n = log2(uv) * 12 + 69; float bpv = (n - 69) / 69.f; - onto.f = bpv * 16 + 16; + ontoThis.f = bpv * 16 + 16; } else { @@ -4071,7 +4076,7 @@ bool Parameter::set_value_from_string_onto(std::string s, pdata &onto) nv = (nv - 1) * 16.f / 31.f + 16; } } - onto.f = nv; + ontoThis.f = nv; } } break; diff --git a/src/common/Parameter.h b/src/common/Parameter.h index 43f04a7b95e..682d32d3d4c 100644 --- a/src/common/Parameter.h +++ b/src/common/Parameter.h @@ -413,8 +413,8 @@ class Parameter float value_to_normalized(float value); float get_default_value_f01(); void set_value_f01(float v, bool force_integer = false); - bool set_value_from_string(std::string s); - bool set_value_from_string_onto(std::string s, pdata &ontoThis); + bool set_value_from_string(const std::string &s); + bool set_value_from_string_onto(const std::string &s, pdata &ontoThis); /* * These two functions convert the modulation depth to a -1,1 range appropriate diff --git a/src/common/SkinColors.h b/src/common/SkinColors.h index d7d9d0f8933..c759a7fdf8e 100644 --- a/src/common/SkinColors.h +++ b/src/common/SkinColors.h @@ -17,8 +17,8 @@ namespace Skin { struct Color { - Color(std::string name, int r, int g, int b); - Color(std::string name, int r, int g, int b, int a); + Color(const std::string &name, int r, int g, int b); + Color(const std::string &name, int r, int g, int b, int a); static Color colorByName(const std::string &name); static std::vector getAllColors(); diff --git a/src/common/SkinModel.h b/src/common/SkinModel.h index 49ebf7c0387..8cc52aad13a 100644 --- a/src/common/SkinModel.h +++ b/src/common/SkinModel.h @@ -294,7 +294,7 @@ struct Connector Connector &asJogPlusMinus() noexcept; - Connector &withProperty(Component::Properties p, std::string v) + Connector &withProperty(Component::Properties p, const std::string &v) { payload->properties[p] = v; return *this; diff --git a/src/common/SkinModelImpl.cpp b/src/common/SkinModelImpl.cpp index ea473445df5..1949937a5b7 100644 --- a/src/common/SkinModelImpl.cpp +++ b/src/common/SkinModelImpl.cpp @@ -277,12 +277,13 @@ std::vector Connector::connectorsByComponentType(const Component &c) return res; } -Color::Color(std::string name, int r, int g, int b) : name(name), r(r), g(g), b(b), a(255) +Color::Color(const std::string &name, int r, int g, int b) : name(name), r(r), g(g), b(b), a(255) { guaranteeMap(); colMap->insert(std::make_pair(name, *this)); } -Color::Color(std::string name, int r, int g, int b, int a) : name(name), r(r), g(g), b(b), a(a) +Color::Color(const std::string &name, int r, int g, int b, int a) + : name(name), r(r), g(g), b(b), a(a) { guaranteeMap(); colMap->insert(std::make_pair(name, *this)); diff --git a/src/common/SurgeSynthesizer.cpp b/src/common/SurgeSynthesizer.cpp index bdfb24f0da1..0d32bc42466 100644 --- a/src/common/SurgeSynthesizer.cpp +++ b/src/common/SurgeSynthesizer.cpp @@ -36,7 +36,7 @@ using namespace std; -SurgeSynthesizer::SurgeSynthesizer(PluginLayer *parent, std::string suppliedDataPath) +SurgeSynthesizer::SurgeSynthesizer(PluginLayer *parent, const std::string &suppliedDataPath) : storage(suppliedDataPath), hpA(&storage), hpB(&storage), _parent(parent), halfbandA(6, true), halfbandB(6, true), halfbandIN(6, true) { diff --git a/src/common/SurgeSynthesizer.h b/src/common/SurgeSynthesizer.h index 374f566234c..d1a42e3c9f2 100644 --- a/src/common/SurgeSynthesizer.h +++ b/src/common/SurgeSynthesizer.h @@ -65,7 +65,7 @@ class alignas(16) SurgeSynthesizer virtual void surgeParameterUpdated(const ID &, float) = 0; virtual void surgeMacroUpdated(long macroNum, float) = 0; }; - SurgeSynthesizer(PluginLayer *parent, std::string suppliedDataPath = ""); + SurgeSynthesizer(PluginLayer *parent, const std::string &suppliedDataPath = ""); virtual ~SurgeSynthesizer(); void playNote(char channel, char key, char velocity, char detune); void releaseNote(char channel, char key, char velocity); diff --git a/src/gui/SkinSupport.cpp b/src/gui/SkinSupport.cpp index e9fdf1433c1..31d56024e26 100644 --- a/src/gui/SkinSupport.cpp +++ b/src/gui/SkinSupport.cpp @@ -719,9 +719,10 @@ bool Skin::reloadSkin(std::shared_ptr bitmapStore) return true; } -bool Skin::setAllCapsProperty(std::string propertyValue) +bool Skin::setAllCapsProperty(const std::string &propertyValueA) { // make the property value not case sensitive + auto propertyValue = propertyValueA; std::transform(propertyValue.begin(), propertyValue.end(), propertyValue.begin(), [](unsigned char c) { return std::tolower(c); }); @@ -735,9 +736,10 @@ bool Skin::setAllCapsProperty(std::string propertyValue) } } -juce::Font::FontStyleFlags Skin::setFontStyleProperty(std::string propertyValue) +juce::Font::FontStyleFlags Skin::setFontStyleProperty(const std::string &propertyValueA) { // make the property value not case sensitive + auto propertyValue = propertyValueA; std::transform(propertyValue.begin(), propertyValue.end(), propertyValue.begin(), [](unsigned char c) { return std::tolower(c); }); @@ -759,9 +761,10 @@ juce::Font::FontStyleFlags Skin::setFontStyleProperty(std::string propertyValue) } } -juce::Justification Skin::setJuceTextAlignProperty(std::string propertyValue) +juce::Justification Skin::setJuceTextAlignProperty(const std::string &propertyValueA) { // make the property value not case sensitive + auto propertyValue = propertyValueA; std::transform(propertyValue.begin(), propertyValue.end(), propertyValue.begin(), [](unsigned char c) { return std::tolower(c); }); diff --git a/src/gui/SkinSupport.h b/src/gui/SkinSupport.h index 348cbcd556e..bb509a761ea 100644 --- a/src/gui/SkinSupport.h +++ b/src/gui/SkinSupport.h @@ -115,9 +115,9 @@ class Skin #endif } - static bool setAllCapsProperty(std::string propertyValue); - static juce::Font::FontStyleFlags setFontStyleProperty(std::string propertyValue); - static juce::Justification setJuceTextAlignProperty(std::string propertyValue); + static bool setAllCapsProperty(const std::string &propertyValue); + static juce::Font::FontStyleFlags setFontStyleProperty(const std::string &propertyValue); + static juce::Justification setJuceTextAlignProperty(const std::string &propertyValue); std::string root; std::string name; @@ -385,9 +385,9 @@ class Skin Type type; ColorStore() : type(COLOR), color(juce::Colours::black) {} - ColorStore(juce::Colour c) : type(COLOR), color(c) {} - ColorStore(std::string a) : type(ALIAS), alias(a) {} - ColorStore(std::string a, Type t) : type(t), alias(a) {} + ColorStore(const juce::Colour &c) : type(COLOR), color(c) {} + ColorStore(const std::string &a) : type(ALIAS), alias(a) {} + ColorStore(const std::string &a, Type t) : type(t), alias(a) {} }; std::unordered_map colors; std::unordered_map imageStringToId; diff --git a/src/gui/SurgeGUIEditor.cpp b/src/gui/SurgeGUIEditor.cpp index a1900b1430e..4ae20af7b2d 100644 --- a/src/gui/SurgeGUIEditor.cpp +++ b/src/gui/SurgeGUIEditor.cpp @@ -1765,7 +1765,7 @@ void SurgeGUIEditor::showTuningMenu(const juce::Point &where, }); } -void SurgeGUIEditor::scaleFileDropped(std::string fn) +void SurgeGUIEditor::scaleFileDropped(const string &fn) { try { @@ -1778,7 +1778,7 @@ void SurgeGUIEditor::scaleFileDropped(std::string fn) } } -void SurgeGUIEditor::mappingFileDropped(std::string fn) +void SurgeGUIEditor::mappingFileDropped(const string &fn) { try { @@ -3517,23 +3517,23 @@ std::string SurgeGUIEditor::helpURLFor(Parameter *p) return ""; } -std::string SurgeGUIEditor::helpURLForSpecial(std::string key) +std::string SurgeGUIEditor::helpURLForSpecial(const string &special) { auto storage = &(synth->storage); - return helpURLForSpecial(storage, key); + return helpURLForSpecial(storage, special); } -std::string SurgeGUIEditor::helpURLForSpecial(SurgeStorage *storage, std::string key) +std::string SurgeGUIEditor::helpURLForSpecial(SurgeStorage *storage, const std::string &special) { - if (storage->helpURL_specials.find(key) != storage->helpURL_specials.end()) + if (storage->helpURL_specials.find(special) != storage->helpURL_specials.end()) { - auto r = storage->helpURL_specials[key]; + auto r = storage->helpURL_specials[special]; if (r != "") return r; } return ""; } -std::string SurgeGUIEditor::fullyResolvedHelpURL(std::string helpurl) +std::string SurgeGUIEditor::fullyResolvedHelpURL(const string &helpurl) { std::string lurl = helpurl; if (helpurl[0] == '#') diff --git a/src/gui/SurgeGUIEditor.h b/src/gui/SurgeGUIEditor.h index 93fa0616e68..ed0639c8d0c 100644 --- a/src/gui/SurgeGUIEditor.h +++ b/src/gui/SurgeGUIEditor.h @@ -275,8 +275,8 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, void toggleMPE(); void toggleTuning(); - void scaleFileDropped(std::string fn); - void mappingFileDropped(std::string fn); + void scaleFileDropped(const std::string &fn); + void mappingFileDropped(const std::string &fn); std::string tuningToHtml(); void modSourceButtonDroppedAt(Surge::Widgets::ModulationSourceButton *msb, @@ -356,7 +356,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, std::string getDisplayForTag(long tag); - void queuePatchFileLoad(std::string file) + void queuePatchFileLoad(const std::string &file) { strncpy(synth->patchid_file, file.c_str(), FILENAME_MAX); synth->has_patchid_file = true; @@ -589,10 +589,11 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, public: std::string helpURLFor(Parameter *p); // this requires internal state so doesn't have statics - std::string helpURLForSpecial(std::string special); // these can be either this way or static + std::string + helpURLForSpecial(const std::string &special); // these can be either this way or static - static std::string helpURLForSpecial(SurgeStorage *, std::string special); - static std::string fullyResolvedHelpURL(std::string helpurl); + static std::string helpURLForSpecial(SurgeStorage *storage, const std::string &special); + static std::string fullyResolvedHelpURL(const std::string &helpurl); private: void promptForUserValueEntry(Parameter *p, juce::Component *c, int modulationSource = -1); diff --git a/src/gui/SurgeGUIUtils.cpp b/src/gui/SurgeGUIUtils.cpp index 960f172029a..c67c4e09898 100644 --- a/src/gui/SurgeGUIUtils.cpp +++ b/src/gui/SurgeGUIUtils.cpp @@ -8,7 +8,7 @@ namespace Surge namespace GUI { -std::string toOSCaseForMenu(std::string menuName) +std::string toOSCaseForMenu(const std::string &menuName) { #if WINDOWS for (auto i = 1; i < menuName.length() - 1; ++i) diff --git a/src/gui/SurgeGUIUtils.h b/src/gui/SurgeGUIUtils.h index d8b0a99ee4e..49f59229296 100644 --- a/src/gui/SurgeGUIUtils.h +++ b/src/gui/SurgeGUIUtils.h @@ -8,7 +8,7 @@ namespace Surge { namespace GUI { -std::string toOSCaseForMenu(std::string menuName); +std::string toOSCaseForMenu(const std::string &menuName); extern bool showCursor(SurgeStorage *storage); diff --git a/src/gui/SurgeImage.cpp b/src/gui/SurgeImage.cpp index a1de78c3e65..8c559e149b5 100644 --- a/src/gui/SurgeImage.cpp +++ b/src/gui/SurgeImage.cpp @@ -29,7 +29,7 @@ SurgeImage::SurgeImage(int rid) } } -SurgeImage::SurgeImage(std::string fname) +SurgeImage::SurgeImage(const std::string &fname) { this->fname = fname; drawable = juce::Drawable::createFromImageFile(juce::File(fname)); @@ -62,7 +62,7 @@ void SurgeImage::setPhysicalZoomFactor(int zoomFactor) } } -void SurgeImage::addPNGForZoomLevel(std::string fname, int zoomLevel) +void SurgeImage::addPNGForZoomLevel(const std::string &fname, int zoomLevel) { pngZooms[zoomLevel] = std::make_pair(fname, nullptr); } diff --git a/src/gui/SurgeImage.h b/src/gui/SurgeImage.h index 9dafe92fd0b..9404ad5cefa 100644 --- a/src/gui/SurgeImage.h +++ b/src/gui/SurgeImage.h @@ -16,10 +16,10 @@ class SurgeImage { public: SurgeImage(int resourceId); - SurgeImage(std::string fname); + SurgeImage(const std::string &fname); ~SurgeImage(); - void addPNGForZoomLevel(std::string fname, int zoomLevel); + void addPNGForZoomLevel(const std::string &fname, int zoomLevel); void resolvePNGForZoomLevel(int zoomLevel); void setPhysicalZoomFactor(int zoomFactor); diff --git a/src/gui/UIInstrumentation.cpp b/src/gui/UIInstrumentation.cpp index afdcdbecd69..c8edb67a8ac 100644 --- a/src/gui/UIInstrumentation.cpp +++ b/src/gui/UIInstrumentation.cpp @@ -15,7 +15,7 @@ namespace Debug { std::unordered_map> records; -void record(std::string tag) { records[tag]++; } +void record(const std::string &tag) { records[tag]++; } void report() { std::ostringstream oss; @@ -34,7 +34,7 @@ void report() Surge::UserInteractions::showHTML(oss.str()); } -TimeThisBlock::TimeThisBlock(std::string i) : tag(i) +TimeThisBlock::TimeThisBlock(const std::string &i) : tag(i) { start = std::chrono::high_resolution_clock::now(); } diff --git a/src/gui/UIInstrumentation.h b/src/gui/UIInstrumentation.h index 50099312d90..b69d8fc904e 100644 --- a/src/gui/UIInstrumentation.h +++ b/src/gui/UIInstrumentation.h @@ -13,7 +13,7 @@ namespace Debug /* ** Just count how many times we hit this function */ -void record(std::string tag); +void record(const std::string &tag); /* ** Pop up the timing report in a browser @@ -29,7 +29,7 @@ void report(); */ struct TimeThisBlock { - TimeThisBlock(std::string tag); + TimeThisBlock(const std::string Ytag); ~TimeThisBlock(); std::string tag; std::chrono::time_point start;