Skip to content

Commit

Permalink
PatchSelector - remove unnecessary uses of .c_str().
Browse files Browse the repository at this point in the history
LFOAndStepDisplay - remove unnessary variable.
Find single chars rather than single character strings, it's faster.
  • Loading branch information
David Lowndes authored and David Lowndes committed Nov 18, 2024
1 parent d006567 commit 68c73f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/common/Parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4680,7 +4680,7 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
}
case ct_pbdepth:
{
if (extend_range && s.find("/") != std::string::npos)
if (extend_range && s.find('/') != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;
Expand Down Expand Up @@ -4813,7 +4813,7 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
if (displayInfo.customFeatures & ParamDisplayFeatures::kAllowsTuningFractionTypein)
{
// Check for a fraction
if (s.find("/") != std::string::npos)
if (s.find('/') != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;
Expand Down Expand Up @@ -5016,7 +5016,7 @@ bool Parameter::set_value_from_string_onto(const std::string &s, pdata &ontoThis
// OK so do we contain a /?
const char *slp;

if ((slp = strstr(strip, "/")) != nullptr)
if ((slp = strchr(strip, '/')) != nullptr)
{
float num = std::atof(strip);
float den = std::atof(slp + 1);
Expand Down Expand Up @@ -5120,7 +5120,7 @@ float Parameter::calculate_modulation_value_from_string(const std::string &s, st
if (displayInfo.customFeatures & ParamDisplayFeatures::kAllowsTuningFractionTypein)
{
// Check for a fraction
if (s.find("/") != std::string::npos)
if (s.find('/') != std::string::npos)
{
if (!supports_tuning_value_from_string(s, errMsg))
return false;
Expand Down Expand Up @@ -5435,7 +5435,7 @@ float Parameter::calculate_modulation_value_from_string(const std::string &s, st
// OK so do we contain a /?
const char *slp;

if ((slp = strstr(strip, "/")) != nullptr)
if ((slp = strchr(strip, '/')) != nullptr)
{
float num = std::atof(strip);
float den = std::atof(slp + 1);
Expand Down
6 changes: 2 additions & 4 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,12 +1335,10 @@ void LFOAndStepDisplay::paintStepSeq(juce::Graphics &g)

auto q = boxo;

auto tf = juce::AffineTransform()
const auto tfpath = juce::AffineTransform()
.scaled(boxo.getWidth() / valScale, boxo.getHeight() / valScale)
.translated(q.getTopLeft().x, q.getTopLeft().y);

auto tfpath = tf;

g.setColour(skin->getColor(Colors::LFO::StepSeq::Envelope));

g.strokePath(eupath, juce::PathStrokeType(1.0), tfpath);
Expand Down Expand Up @@ -2609,7 +2607,7 @@ void LFOAndStepDisplay::showStepTypein(int i)
}

auto handleTypein = [this, i](const std::string &s) {
auto divPos = s.find("/");
auto divPos = s.find('/');
float v = 0.f;

if (divPos != std::string::npos)
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/widgets/PatchSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,11 @@ bool PatchSelector::populatePatchMenuForCategory(int c, juce::PopupMenu &context

if (n_subc > 1)
{
name = fmt::format("{} {}", menuName, subc + 1).c_str();
name = fmt::format("{} {}", menuName, subc + 1);
}
else
{
name = menuName.c_str();
name = menuName;
}

if (!single_category)
Expand Down

0 comments on commit 68c73f8

Please sign in to comment.