Skip to content

Commit

Permalink
Misc1 (#7859)
Browse files Browse the repository at this point in the history
PatchSelector - remove unnecessary uses of .c_str().
LFOAndStepDisplay - remove unnessary variable.
Find single chars rather than single character strings, it's faster.

---------

Co-authored-by: David Lowndes <David@DAVIDPCZ>
  • Loading branch information
Dave-Lowndes and David Lowndes authored Nov 21, 2024
1 parent 9ad1f54 commit 249e297
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 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
10 changes: 4 additions & 6 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,11 +1335,9 @@ void LFOAndStepDisplay::paintStepSeq(juce::Graphics &g)

auto q = boxo;

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

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

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

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 249e297

Please sign in to comment.