Skip to content

Commit

Permalink
Tiny optimization (#1325)
Browse files Browse the repository at this point in the history
So I've started running it in the profiler and the obvious stuff
like running-unused-lfos and summing-unused-busses is dominant
but funnily the if in getEngine showed up as a 3% usage when
playing basic samples, so knock that out.
  • Loading branch information
baconpaul authored Sep 14, 2024
1 parent 41b7dfd commit 469a852
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/engine/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ struct Group : MoveableOnly<Group>,
size_t addZone(std::unique_ptr<Zone> &z)
{
z->parentGroup = this;
z->engine = getEngine();
zones.push_back(std::move(z));
return zones.size();
}

size_t addZone(std::unique_ptr<Zone> &&z)
{
z->parentGroup = this;
z->engine = getEngine();
zones.push_back(std::move(z));
return zones.size();
}
Expand Down
14 changes: 0 additions & 14 deletions src/engine/zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,6 @@ void Zone::clearNormalizedSampleLevel(const int associatedSampleID)
}
}

engine::Engine *Zone::getEngine()
{
if (parentGroup && parentGroup->parentPart && parentGroup->parentPart->parentPatch)
return parentGroup->parentPart->parentPatch->parentEngine;
return nullptr;
}

const engine::Engine *Zone::getEngine() const
{
if (parentGroup && parentGroup->parentPart && parentGroup->parentPart->parentPatch)
return parentGroup->parentPart->parentPatch->parentEngine;
return nullptr;
}

void Zone::initialize()
{
for (auto &v : voiceWeakPointers)
Expand Down
13 changes: 11 additions & 2 deletions src/engine/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,17 @@ struct Zone : MoveableOnly<Zone>, HasGroupZoneProcessors<Zone>, SampleRateSuppor
void onProcessorTypeChanged(int, dsp::processor::ProcessorType) {}

void setupOnUnstream(const engine::Engine &e);
engine::Engine *getEngine();
const engine::Engine *getEngine() const;
engine::Engine *engine{nullptr};
engine::Engine *getEngine()
{
assert(engine);
return engine;
}
const engine::Engine *getEngine() const
{
assert(engine);
return engine;
}

sst::basic_blocks::dsp::UIComponentLagHandler mUILag;
void onSampleRateChanged() override;
Expand Down

0 comments on commit 469a852

Please sign in to comment.