Skip to content

Commit

Permalink
engine: Prefer standard algorithms
Browse files Browse the repository at this point in the history
Minor refactor to reduce codebase size by using standard algorithm
functions.
  • Loading branch information
tcoyvwac committed Feb 1, 2023
1 parent 80fed1d commit 55157e7
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/engine/enginemaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,10 @@ void EngineMaster::addChannel(EngineChannel* pChannel) {
}

EngineChannel* EngineMaster::getChannel(const QString& group) {
for (int i = 0; i < m_channels.size(); ++i) {
ChannelInfo* pChannelInfo = m_channels[i];
if (pChannelInfo->m_pChannel->getGroup() == group) {
return pChannelInfo->m_pChannel;
}
}
return nullptr;
const auto it = std::find_if(std::begin(m_channels), std::end(m_channels), [&](const auto* pChannelInfo) {
return (pChannelInfo->m_pChannel->getGroup() == group);
});
return (it != std::end(m_channels)) ? (*it)->m_pChannel : nullptr;
}

CSAMPLE_GAIN EngineMaster::getMasterGain(int channelIndex) const {
Expand All @@ -896,13 +893,10 @@ const CSAMPLE* EngineMaster::getOutputBusBuffer(unsigned int i) const {
}

const CSAMPLE* EngineMaster::getChannelBuffer(const QString& group) const {
for (int i = 0; i < m_channels.size(); ++i) {
const ChannelInfo* pChannelInfo = m_channels[i];
if (pChannelInfo->m_pChannel->getGroup() == group) {
return pChannelInfo->m_pBuffer;
}
}
return nullptr;
const auto it = std::find_if(std::begin(m_channels), std::end(m_channels), [&](const auto* pChannelInfo) {
return (pChannelInfo->m_pChannel->getGroup() == group);
});
return (it != std::end(m_channels)) ? (*it)->m_pBuffer : nullptr;
}

const CSAMPLE* EngineMaster::buffer(const AudioOutput& output) const {
Expand Down

0 comments on commit 55157e7

Please sign in to comment.