Skip to content

Commit

Permalink
Clean up a couple for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Mar 30, 2024
1 parent ed90d0f commit ef9fd77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/dspatch/Circuit.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,9 @@ inline void Circuit::_Optimize()
std::vector<std::vector<DSPatch::Component*>> componentsMap;
componentsMap.reserve( _components.size() );

int scanPosition;
for ( int i = (int)_components.size() - 1; i >= 0; --i )
{
int scanPosition;
_components[i]->ScanParallel( componentsMap, scanPosition );
}
for ( auto component : _components )
Expand Down
13 changes: 8 additions & 5 deletions include/dspatch/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ inline Component::~Component() = default;

inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int fromOutput, int toInput )
{
if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= _inputBuses[0].GetSignalCount() )
if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= GetInputCount() )
{
return false;
}
Expand All @@ -206,7 +206,7 @@ inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int f
if ( it->fromComponent == fromComponent.get() && it->fromOutput == fromOutput )
{
// this wire already exists
return false;
return true;
}

// update source output's reference count
Expand Down Expand Up @@ -320,13 +320,16 @@ inline void Component::SetBufferCount( int bufferCount, int startBuffer )
_releaseFlags.resize( bufferCount );

_refs.resize( bufferCount );
auto refCount = _refs[0].size();

const auto inputCount = GetInputCount();
const auto outputCount = GetOutputCount();
const auto refCount = _refs[0].size();

// init vector values
for ( int i = 0; i < bufferCount; ++i )
{
_inputBuses[i].SetSignalCount( _inputBuses[0].GetSignalCount() );
_outputBuses[i].SetSignalCount( _outputBuses[0].GetSignalCount() );
_inputBuses[i].SetSignalCount( inputCount );
_outputBuses[i].SetSignalCount( outputCount );

if ( i == startBuffer )
{
Expand Down

0 comments on commit ef9fd77

Please sign in to comment.