From ef9fd770a891b4f15b1725bb9e0fbe104cec6ca2 Mon Sep 17 00:00:00 2001 From: Marcus Tomlinson Date: Sat, 30 Mar 2024 13:51:26 +0000 Subject: [PATCH] Clean up a couple for loops --- include/dspatch/Circuit.h | 2 +- include/dspatch/Component.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/dspatch/Circuit.h b/include/dspatch/Circuit.h index 9c31c2f5..1c2b80be 100644 --- a/include/dspatch/Circuit.h +++ b/include/dspatch/Circuit.h @@ -796,9 +796,9 @@ inline void Circuit::_Optimize() std::vector> 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 ) diff --git a/include/dspatch/Component.h b/include/dspatch/Component.h index ed0d8d11..9083fcae 100644 --- a/include/dspatch/Component.h +++ b/include/dspatch/Component.h @@ -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; } @@ -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 @@ -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 ) {