diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 7b11f0646..7565b4043 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -414,6 +414,7 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector { QVector historyPP; + historyPP.reserve(history.size()); for (qint32 i = 0; i < history.size(); ++i) { const VToolRecord &tool = history.at(i); @@ -733,8 +734,9 @@ auto VAbstractPattern::ParsePieceNodes(const QDomElement &domElement) -> VPieceP //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPattern::ParsePieceCSARecords(const QDomElement &domElement) -> QVector { - QVector records; const QDomNodeList nodeList = domElement.childNodes(); + QVector records; + records.reserve(nodeList.size()); for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); @@ -756,8 +758,9 @@ auto VAbstractPattern::ParsePieceCSARecords(const QDomElement &domElement) -> QV //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPattern::ParsePieceInternalPaths(const QDomElement &domElement) -> QVector { - QVector records; const QDomNodeList nodeList = domElement.childNodes(); + QVector records; + records.reserve(nodeList.size()); for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); @@ -1759,6 +1762,7 @@ auto VAbstractPattern::ListIncrements() const -> QStringList auto GetExpressions = [&increments, this](const QString &type) { const QDomNodeList list = elementsByTagName(type); + increments.reserve(list.size()); for (int i = 0; i < list.size(); ++i) { const QString name = GetParametrEmptyString(list.at(i).toElement(), AttrName); @@ -2636,6 +2640,7 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap bool @@ -60,7 +62,7 @@ auto VAbstartMeasurementDimension::RangeMin() const -> int const int rangeMinMm = 200; const int rangeMinInch = 8; - switch(Units()) + switch (Units()) { case Unit::Cm: return rangeMinCm; @@ -85,7 +87,7 @@ auto VAbstartMeasurementDimension::RangeMax() const -> int const int rangeMaxMm = 2720; const int rangeMaxInch = 107; - switch(Units()) + switch (Units()) { case Unit::Cm: return rangeMaxCm; @@ -135,8 +137,7 @@ auto VAbstartMeasurementDimension::ValidSteps() const -> QVector } candidate = 1 + s * i; ++i; - } - while(candidate < stepBarrier); + } while (candidate < stepBarrier); } return steps; @@ -159,12 +160,11 @@ auto VAbstartMeasurementDimension::ValidBasesList() const -> QStringList list.append(QString::number(base)); } return list; - } //--------------------------------------------------------------------------------------------------------------------- -auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step, - const QSet &exclude) -> QVector +auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step, const QSet &exclude) + -> QVector { QVector validBases; @@ -190,8 +190,7 @@ auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step, } value = min + step * i; ++i; - } - while(value < max + step); + } while (value < max + step); if (validBases.isEmpty()) { @@ -202,8 +201,7 @@ auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step, validBases.append(value); value = min + step * i; ++i; - } - while(value < max + step); + } while (value < max + step); } return validBases; @@ -265,7 +263,7 @@ auto VAbstartMeasurementDimension::IsUnitsValid() const -> bool //--------------------------------------------------------------------------------------------------------------------- auto VAbstartMeasurementDimension::DimensionName(MeasurementDimension type) -> QString { - switch(type) + switch (type) { case MeasurementDimension::X: return QCoreApplication::translate("VAbstartMeasurementDimension", "Height", "dimension"); @@ -288,7 +286,7 @@ auto VAbstartMeasurementDimension::DimensionToolTip(const MeasurementDimension_p return {}; } - switch(dimension->Type()) + switch (dimension->Type()) { case MeasurementDimension::Y: if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement()) @@ -326,51 +324,59 @@ auto VAbstartMeasurementDimension::DimensionToolTip(const MeasurementDimension_p // VXMeasurementDimension //--------------------------------------------------------------------------------------------------------------------- VXMeasurementDimension::VXMeasurementDimension(Unit units) - : VAbstartMeasurementDimension(units) -{} + : VAbstartMeasurementDimension(units) +{ +} //--------------------------------------------------------------------------------------------------------------------- VXMeasurementDimension::VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step) - : VAbstartMeasurementDimension(units, min, max, step) -{} + : VAbstartMeasurementDimension(units, min, max, step) +{ +} // VYMeasurementDimension //--------------------------------------------------------------------------------------------------------------------- VYMeasurementDimension::VYMeasurementDimension(Unit units) - : VAbstartMeasurementDimension(units) -{} + : VAbstartMeasurementDimension(units) +{ +} //--------------------------------------------------------------------------------------------------------------------- VYMeasurementDimension::VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step) - : VAbstartMeasurementDimension(units, min, max, step) -{} + : VAbstartMeasurementDimension(units, min, max, step) +{ +} // VWMeasurementDimension //--------------------------------------------------------------------------------------------------------------------- VWMeasurementDimension::VWMeasurementDimension(Unit units) - : VAbstartMeasurementDimension(units) -{} + : VAbstartMeasurementDimension(units) +{ +} //--------------------------------------------------------------------------------------------------------------------- VWMeasurementDimension::VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step) - : VAbstartMeasurementDimension(units, min, max, step) -{} + : VAbstartMeasurementDimension(units, min, max, step) +{ +} // VZMeasurementDimension //--------------------------------------------------------------------------------------------------------------------- VZMeasurementDimension::VZMeasurementDimension(Unit units) - : VAbstartMeasurementDimension(units) -{} + : VAbstartMeasurementDimension(units) +{ +} //--------------------------------------------------------------------------------------------------------------------- VZMeasurementDimension::VZMeasurementDimension(Unit units, qreal min, qreal max, qreal step) - : VAbstartMeasurementDimension(units, min, max, step) -{} + : VAbstartMeasurementDimension(units, min, max, step) +{ +} // VDimensionRestriction //--------------------------------------------------------------------------------------------------------------------- -VDimensionRestriction::VDimensionRestriction(qreal min, qreal max, const QString &exclude) : - m_min(min), +VDimensionRestriction::VDimensionRestriction(qreal min, qreal max, const QString &exclude) + : m_min(min), m_max(max) { SetExcludeString(exclude); @@ -399,6 +405,7 @@ auto VDimensionRestriction::GetExcludeString() const -> QString { QList const list = m_exclude.values(); QStringList excludeList; + excludeList.reserve(list.size()); for (const auto &value : list) { diff --git a/src/libs/vlayout/vlayoutgenerator.cpp b/src/libs/vlayout/vlayoutgenerator.cpp index e89480907..5264823df 100644 --- a/src/libs/vlayout/vlayoutgenerator.cpp +++ b/src/libs/vlayout/vlayoutgenerator.cpp @@ -680,6 +680,7 @@ auto VLayoutGenerator::MoveDetails(qreal length, const QVector &de } QList newDetails; + newDetails.reserve(details.size()); for (auto d : details) { IsPortrait() ? d.Translate(0, length) : d.Translate(length, 0); diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index 4cba90034..bbb98011f 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -213,6 +213,7 @@ void VObjEngine::drawPath(const QPainterPath &path) if (skipFace == false) { QPolygonF face; + face.reserve(num_verts); for (int ind = 0; ind < num_verts; ind++) { face << QPointF(pf[ind]); @@ -334,13 +335,16 @@ auto VObjEngine::MakePointsUnique(const QPolygonF &polygon) const -> QPolygonF //--------------------------------------------------------------------------------------------------------------------- auto VObjEngine::Square(const QPolygonF &poly) const -> qint64 { - QVector x; - QVector y; - vsizetype const n = poly.count(); qreal s, res = 0; qint64 sq = 0; + QVector x; + QVector y; + + x.reserve(n); + y.reserve(n); + for (int i = 0; i < n; i++) { x.append(poly.at(i).x());