Skip to content

Commit ed90d0f

Browse files
Optimize Component::ConnectInput()
1 parent 641e554 commit ed90d0f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

include/dspatch/Component.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,15 @@ inline bool Component::ConnectInput( const Component::SPtr& fromComponent, int f
212212
// update source output's reference count
213213
it->fromComponent->_DecRefs( it->fromOutput );
214214

215-
_inputWires.erase( it );
215+
// replace wire
216+
it->fromComponent = fromComponent.get();
217+
it->fromOutput = fromOutput;
218+
}
219+
else
220+
{
221+
// add new wire
222+
_inputWires.emplace_back( Wire{ fromComponent.get(), fromOutput, toInput } );
216223
}
217-
218-
_inputWires.emplace_back( Wire{ fromComponent.get(), fromOutput, toInput } );
219224

220225
// update source output's reference count
221226
fromComponent->_IncRefs( fromOutput );

0 commit comments

Comments
 (0)