Skip to content

Commit ef9fd77

Browse files
Clean up a couple for loops
1 parent ed90d0f commit ef9fd77

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/dspatch/Circuit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,9 @@ inline void Circuit::_Optimize()
796796
std::vector<std::vector<DSPatch::Component*>> componentsMap;
797797
componentsMap.reserve( _components.size() );
798798

799+
int scanPosition;
799800
for ( int i = (int)_components.size() - 1; i >= 0; --i )
800801
{
801-
int scanPosition;
802802
_components[i]->ScanParallel( componentsMap, scanPosition );
803803
}
804804
for ( auto component : _components )

include/dspatch/Component.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ inline Component::~Component() = default;
193193

194194
inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int fromOutput, int toInput )
195195
{
196-
if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= _inputBuses[0].GetSignalCount() )
196+
if ( fromOutput >= fromComponent->GetOutputCount() || toInput >= GetInputCount() )
197197
{
198198
return false;
199199
}
@@ -206,7 +206,7 @@ inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int f
206206
if ( it->fromComponent == fromComponent.get() && it->fromOutput == fromOutput )
207207
{
208208
// this wire already exists
209-
return false;
209+
return true;
210210
}
211211

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

322322
_refs.resize( bufferCount );
323-
auto refCount = _refs[0].size();
323+
324+
const auto inputCount = GetInputCount();
325+
const auto outputCount = GetOutputCount();
326+
const auto refCount = _refs[0].size();
324327

325328
// init vector values
326329
for ( int i = 0; i < bufferCount; ++i )
327330
{
328-
_inputBuses[i].SetSignalCount( _inputBuses[0].GetSignalCount() );
329-
_outputBuses[i].SetSignalCount( _outputBuses[0].GetSignalCount() );
331+
_inputBuses[i].SetSignalCount( inputCount );
332+
_outputBuses[i].SetSignalCount( outputCount );
330333

331334
if ( i == startBuffer )
332335
{

0 commit comments

Comments
 (0)