Minor refactoring

This commit is contained in:
llocram 2020-08-28 13:57:14 +02:00
parent 07858f7fcb
commit ed970fe6f6

View File

@ -175,7 +175,7 @@ QVector<VSAPoint> PrepareAllowance(const QVector<QPointF> &points)
{ {
QVector<VSAPoint> allowancePoints; QVector<VSAPoint> allowancePoints;
allowancePoints.reserve(points.size()); allowancePoints.reserve(points.size());
for(auto point : points) for(auto &point : points)
{ {
allowancePoints.append(VSAPoint(point)); allowancePoints.append(VSAPoint(point));
} }
@ -206,8 +206,9 @@ QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManage
QStringList text; QStringList text;
if (labelShape.count() > 2) if (labelShape.count() > 2)
{ {
text.reserve(tm.GetSourceLinesCount()); int sourceCount = tm.GetSourceLinesCount();
for (int i = 0; i < tm.GetSourceLinesCount(); ++i) text.reserve(sourceCount);
for (int i = 0; i < sourceCount; ++i)
{ {
text.append(tm.GetSourceLine(i).m_qsText); text.append(tm.GetSourceLine(i).m_qsText);
} }
@ -219,9 +220,9 @@ QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManage
QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern)
{ {
QVector<VLayoutPlaceLabel> labels; QVector<VLayoutPlaceLabel> labels;
const QVector<quint32> placeLabels = piece.GetPlaceLabels(); const auto placeLabels = piece.GetPlaceLabels();
labels.reserve(placeLabels.size()); labels.reserve(placeLabels.size());
for(auto placeLabel : placeLabels) for(auto &placeLabel : placeLabels)
{ {
const auto label = pattern->GeometricObject<VPlaceLabelItem>(placeLabel); const auto label = pattern->GeometricObject<VPlaceLabelItem>(placeLabel);
if (label->IsVisible()) if (label->IsVisible())