Skip to content

Commit fca0d2c

Browse files
committed
[algorithm] use references to avoid copies for container variables - (const where appropriate)
1 parent 64d8c5b commit fca0d2c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class InsertionAlgorithm : public BaseAlgorithm
8080
return;
8181
vparams->drawTool()->disableLighting();
8282

83-
DetectionOutput collisionOutput = d_collisionOutput.getValue();
83+
const AlgorithmOutput& collisionOutput = d_collisionOutput.getValue();
8484
for (const auto& it : collisionOutput)
8585
{
8686
vparams->drawTool()->drawLine(it.first->getPosition(), it.second->getPosition(),
8787
type::RGBAColor(0, 1, 0, 1));
8888
}
8989

90-
DetectionOutput insertionOutput = d_insertionOutput.getValue();
90+
const AlgorithmOutput& insertionOutput = d_insertionOutput.getValue();
9191
for (const auto& it : insertionOutput)
9292
{
9393
vparams->drawTool()->drawSphere(it.first->getPosition(), d_drawPointsScale.getValue(),
@@ -111,7 +111,7 @@ class InsertionAlgorithm : public BaseAlgorithm
111111
const MechStateTipType::SPtr mstate = l_tipGeom->getContext()->get<MechStateTipType>();
112112
if (m_constraintSolver)
113113
{
114-
const auto lambda =
114+
const auto& lambda =
115115
m_constraintSolver->getLambda()[mstate.get()].read()->getValue();
116116
if (lambda[0].norm() > d_punctureForceThreshold.getValue())
117117
{
@@ -184,7 +184,7 @@ class InsertionAlgorithm : public BaseAlgorithm
184184
const type::Vec3 normal = (edgeProx->element()->getP1()->getPosition() -
185185
edgeProx->element()->getP0()->getPosition())
186186
.normalized();
187-
type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition();
187+
const type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition();
188188
const SReal dotProd = dot(ab, normal);
189189
if (dotProd > 0.0)
190190
{

0 commit comments

Comments
 (0)