Code smell and performance : capture various variables by reference
This commit is contained in:
parent
a1cf176331
commit
95db2eb133
|
@ -84,7 +84,7 @@ auto VBestSquare::operator=(VBestSquare &&res) noexcept -> VBestSquare &
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VBestSquare::NewResult(const VBestSquareResData &data)
|
void VBestSquare::NewResult(const VBestSquareResData &data)
|
||||||
{
|
{
|
||||||
auto SaveResult = [this, data]()
|
auto SaveResult = [this, &data]()
|
||||||
{
|
{
|
||||||
d->valideResult = true;
|
d->valideResult = true;
|
||||||
d->data = data;
|
d->data = data;
|
||||||
|
|
|
@ -459,7 +459,7 @@ auto VFoldLine::FoldLineThreeDotsPath() const -> QVector<QPainterPath>
|
||||||
ThreeDotsPosData const data = ThreeDotsData();
|
ThreeDotsPosData const data = ThreeDotsData();
|
||||||
QPainterPath dots;
|
QPainterPath dots;
|
||||||
|
|
||||||
auto DrawCircle = [&dots, data](const QPointF ¢er)
|
auto DrawCircle = [&dots, &data](const QPointF ¢er)
|
||||||
{
|
{
|
||||||
qreal const diameter = 2 * data.radius;
|
qreal const diameter = 2 * data.radius;
|
||||||
qreal const x = center.x() - data.radius;
|
qreal const x = center.x() - data.radius;
|
||||||
|
|
|
@ -1693,7 +1693,7 @@ auto VLayoutPiece::GetItem(bool textAsPaths, bool togetherWithNotches, bool show
|
||||||
QVector<VLayoutPoint> points = path.Points();
|
QVector<VLayoutPoint> points = path.Points();
|
||||||
const QTransform matrix = VGObject::FlippingMatrix(d->m_seamMirrorLine);
|
const QTransform matrix = VGObject::FlippingMatrix(d->m_seamMirrorLine);
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
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;
|
QVector<QPointF> casted;
|
||||||
CastTo(points, casted);
|
CastTo(points, casted);
|
||||||
p.addPath(d->m_matrix.map(VPiecePath::MakePainterPath(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)
|
for (auto &points : shape)
|
||||||
{
|
{
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
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)));
|
path.addPath(d->m_matrix.map(LabelShapePath(shape)));
|
||||||
|
@ -2382,7 +2382,7 @@ auto VLayoutPiece::ConvertPassmarks(const VPiece &piece, const VContainer *patte
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AddPassmark = [passmark, piece, pattern, &layoutPassmarks](PassmarkSide side)
|
auto AddPassmark = [&passmark, &piece, pattern, &layoutPassmarks](PassmarkSide side)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
VLayoutPassmark const layoutPassmark = PrepareSAPassmark(piece, pattern, passmark, side, ok);
|
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;
|
bool ok = false;
|
||||||
VLayoutPassmark const layoutPassmark = PreapreBuiltInSAPassmark(piece, pattern, passmark, ok);
|
VLayoutPassmark const layoutPassmark = PreapreBuiltInSAPassmark(piece, pattern, passmark, ok);
|
||||||
|
|
|
@ -95,7 +95,7 @@ auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal
|
auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal
|
||||||
{
|
{
|
||||||
auto ValidateLength = [passmarkData](qreal length)
|
auto ValidateLength = [&passmarkData](qreal length)
|
||||||
{
|
{
|
||||||
if (length <= accuracyPointOnLine)
|
if (length <= accuracyPointOnLine)
|
||||||
{
|
{
|
||||||
|
|
|
@ -404,7 +404,7 @@ auto VPiece::PlaceLabelPath(const VContainer *data) const -> QPainterPath
|
||||||
for (auto &points : shape)
|
for (auto &points : shape)
|
||||||
{
|
{
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
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));
|
path.addPath(LabelShapePath(shape));
|
||||||
|
|
|
@ -271,7 +271,7 @@ void DialogArc::ShowDialog(bool click)
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
|
||||||
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
|
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
|
||||||
|
|
||||||
auto Angle = [line]()
|
auto Angle = [&line]()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
|
|
|
@ -298,7 +298,7 @@ void DialogArcWithLength::ShowDialog(bool click)
|
||||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
|
||||||
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
|
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
|
||||||
|
|
||||||
auto Angle = [line]()
|
auto Angle = [&line]()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
|
|
|
@ -592,7 +592,7 @@ void DialogEllipticalArc::ShowDialog(bool click)
|
||||||
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCenter());
|
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCenter());
|
||||||
QLineF line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
|
QLineF line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
|
||||||
|
|
||||||
auto Angle = [line]()
|
auto Angle = [&line]()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
|
||||||
|
|
||||||
QScopedPointer<QMenu> menu(new QMenu());
|
QScopedPointer<QMenu> menu(new QMenu());
|
||||||
|
|
||||||
auto InitAction = [currentLabel, &menu](const QString &text, PlaceLabelType type)
|
auto InitAction = [¤tLabel, &menu](const QString &text, PlaceLabelType type)
|
||||||
{
|
{
|
||||||
QAction *action = menu->addAction(text);
|
QAction *action = menu->addAction(text);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
|
@ -1326,7 +1326,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
|
||||||
return action;
|
return action;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto SaveType = [this, currentLabel, labelId](PlaceLabelType type)
|
auto SaveType = [this, ¤tLabel, labelId](PlaceLabelType type)
|
||||||
{
|
{
|
||||||
VPlaceLabelItem newLabel = VPlaceLabelItem(currentLabel);
|
VPlaceLabelItem newLabel = VPlaceLabelItem(currentLabel);
|
||||||
newLabel.SetLabelType(type);
|
newLabel.SetLabelType(type);
|
||||||
|
|
|
@ -328,7 +328,7 @@ void VToolPiecePath::RefreshGeometry()
|
||||||
QVector<VLayoutPoint> points = path.PathPoints(this->getData(), cuttingPath);
|
QVector<VLayoutPoint> points = path.PathPoints(this->getData(), cuttingPath);
|
||||||
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
|
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
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;
|
QVector<QPointF> casted;
|
||||||
CastTo(points, casted);
|
CastTo(points, casted);
|
||||||
p.addPath(VPiecePath::MakePainterPath(casted));
|
p.addPath(VPiecePath::MakePainterPath(casted));
|
||||||
|
|
|
@ -1559,7 +1559,7 @@ void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre
|
||||||
piece->RefreshGeometry(true); // Refresh internal paths
|
piece->RefreshGeometry(true); // Refresh internal paths
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DuplicateDetail = [initData](quint32 id)
|
auto DuplicateDetail = [&initData](quint32 id)
|
||||||
{
|
{
|
||||||
VToolSeamAllowanceInitData initPieceData;
|
VToolSeamAllowanceInitData initPieceData;
|
||||||
initPieceData.scene = initData.scene;
|
initPieceData.scene = initData.scene;
|
||||||
|
|
|
@ -67,7 +67,7 @@ void VisToolArc::RefreshGeometry()
|
||||||
{
|
{
|
||||||
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
|
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
|
||||||
|
|
||||||
auto Angle = [r]()
|
auto Angle = [&r]()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,7 @@ void VisToolArcWithLength::RefreshGeometry()
|
||||||
{
|
{
|
||||||
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
|
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos());
|
||||||
|
|
||||||
auto Angle = [r]()
|
auto Angle = [&r]()
|
||||||
{
|
{
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user