Code smell and performance : capture various variables by reference

develop
Yann Lossouarn 2024-02-23 22:05:30 +01:00
parent a1cf176331
commit 95db2eb133
13 changed files with 17 additions and 17 deletions

View File

@ -84,7 +84,7 @@ auto VBestSquare::operator=(VBestSquare &&res) noexcept -> VBestSquare &
//---------------------------------------------------------------------------------------------------------------------
void VBestSquare::NewResult(const VBestSquareResData &data)
{
auto SaveResult = [this, data]()
auto SaveResult = [this, &data]()
{
d->valideResult = true;
d->data = data;

View File

@ -459,7 +459,7 @@ auto VFoldLine::FoldLineThreeDotsPath() const -> QVector<QPainterPath>
ThreeDotsPosData const data = ThreeDotsData();
QPainterPath dots;
auto DrawCircle = [&dots, data](const QPointF &center)
auto DrawCircle = [&dots, &data](const QPointF &center)
{
qreal const diameter = 2 * data.radius;
qreal const x = center.x() - data.radius;

View File

@ -1693,7 +1693,7 @@ auto VLayoutPiece::GetItem(bool textAsPaths, bool togetherWithNotches, bool show
QVector<VLayoutPoint> points = path.Points();
const QTransform matrix = VGObject::FlippingMatrix(d->m_seamMirrorLine);
std::transform(points.begin(), points.end(), points.begin(),
[matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
[&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
QVector<QPointF> casted;
CastTo(points, casted);
p.addPath(d->m_matrix.map(VPiecePath::MakePainterPath(casted)));
@ -1724,7 +1724,7 @@ auto VLayoutPiece::GetItem(bool textAsPaths, bool togetherWithNotches, bool show
for (auto &points : shape)
{
std::transform(points.begin(), points.end(), points.begin(),
[matrix](const VLayoutPoint &point) { return MapPoint(point, matrix); });
[&matrix](const VLayoutPoint &point) { return MapPoint(point, matrix); });
}
path.addPath(d->m_matrix.map(LabelShapePath(shape)));
@ -2382,7 +2382,7 @@ auto VLayoutPiece::ConvertPassmarks(const VPiece &piece, const VContainer *patte
continue;
}
auto AddPassmark = [passmark, piece, pattern, &layoutPassmarks](PassmarkSide side)
auto AddPassmark = [&passmark, &piece, pattern, &layoutPassmarks](PassmarkSide side)
{
bool ok = false;
VLayoutPassmark const layoutPassmark = PrepareSAPassmark(piece, pattern, passmark, side, ok);
@ -2392,7 +2392,7 @@ auto VLayoutPiece::ConvertPassmarks(const VPiece &piece, const VContainer *patte
}
};
auto AddBuiltInPassmark = [passmark, piece, pattern, &layoutPassmarks]()
auto AddBuiltInPassmark = [&passmark, &piece, pattern, &layoutPassmarks]()
{
bool ok = false;
VLayoutPassmark const layoutPassmark = PreapreBuiltInSAPassmark(piece, pattern, passmark, ok);

View File

@ -95,7 +95,7 @@ auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
//---------------------------------------------------------------------------------------------------------------------
auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal
{
auto ValidateLength = [passmarkData](qreal length)
auto ValidateLength = [&passmarkData](qreal length)
{
if (length <= accuracyPointOnLine)
{

View File

@ -404,7 +404,7 @@ auto VPiece::PlaceLabelPath(const VContainer *data) const -> QPainterPath
for (auto &points : shape)
{
std::transform(points.begin(), points.end(), points.begin(),
[matrix](const VLayoutPoint &point) { return MapPoint(point, matrix); });
[&matrix](const VLayoutPoint &point) { return MapPoint(point, matrix); });
}
path.addPath(LabelShapePath(shape));

View File

@ -271,7 +271,7 @@ void DialogArc::ShowDialog(bool click)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
auto Angle = [line]()
auto Angle = [&line]()
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{

View File

@ -298,7 +298,7 @@ void DialogArcWithLength::ShowDialog(bool click)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
auto Angle = [line]()
auto Angle = [&line]()
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{

View File

@ -592,7 +592,7 @@ void DialogEllipticalArc::ShowDialog(bool click)
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCenter());
QLineF line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
auto Angle = [line]()
auto Angle = [&line]()
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{

View File

@ -1318,7 +1318,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
QScopedPointer<QMenu> menu(new QMenu());
auto InitAction = [currentLabel, &menu](const QString &text, PlaceLabelType type)
auto InitAction = [&currentLabel, &menu](const QString &text, PlaceLabelType type)
{
QAction *action = menu->addAction(text);
action->setCheckable(true);
@ -1326,7 +1326,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
return action;
};
auto SaveType = [this, currentLabel, labelId](PlaceLabelType type)
auto SaveType = [this, &currentLabel, labelId](PlaceLabelType type)
{
VPlaceLabelItem newLabel = VPlaceLabelItem(currentLabel);
newLabel.SetLabelType(type);

View File

@ -328,7 +328,7 @@ void VToolPiecePath::RefreshGeometry()
QVector<VLayoutPoint> points = path.PathPoints(this->getData(), cuttingPath);
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
std::transform(points.begin(), points.end(), points.begin(),
[matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
[&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
QVector<QPointF> casted;
CastTo(points, casted);
p.addPath(VPiecePath::MakePainterPath(casted));

View File

@ -1559,7 +1559,7 @@ void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre
piece->RefreshGeometry(true); // Refresh internal paths
}
auto DuplicateDetail = [initData](quint32 id)
auto DuplicateDetail = [&initData](quint32 id)
{
VToolSeamAllowanceInitData initPieceData;
initPieceData.scene = initData.scene;

View File

@ -67,7 +67,7 @@ void VisToolArc::RefreshGeometry()
{
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
auto Angle = [r]()
auto Angle = [&r]()
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{

View File

@ -65,7 +65,7 @@ void VisToolArcWithLength::RefreshGeometry()
{
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
auto Angle = [r]()
auto Angle = [&r]()
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{