Refactoring.
Fix places that could use a reserve() call.
This commit is contained in:
parent
afd948b330
commit
f1081a2aad
|
@ -414,6 +414,7 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool
|
|||
auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector<VToolRecord>
|
||||
{
|
||||
QVector<VToolRecord> 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<CustomSARecord>
|
||||
{
|
||||
QVector<CustomSARecord> records;
|
||||
const QDomNodeList nodeList = domElement.childNodes();
|
||||
QVector<CustomSARecord> 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<quint32>
|
||||
{
|
||||
QVector<quint32> records;
|
||||
const QDomNodeList nodeList = domElement.childNodes();
|
||||
QVector<quint32> 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<quint3
|
|||
|
||||
const QDomNodeList nodeList = group.childNodes();
|
||||
const qint32 num = nodeList.size();
|
||||
items.reserve(num);
|
||||
for (qint32 i = 0; i < num; ++i)
|
||||
{
|
||||
const QDomElement element = nodeList.at(i).toElement();
|
||||
|
|
|
@ -2238,6 +2238,7 @@ void VPatternConverter::TagUnionDetailsToV0_4_0()
|
|||
QDomElement tagChildrenNodes = createElement(*strChildren);
|
||||
|
||||
const QDomNodeList childList = toolDOM.childNodes();
|
||||
nodes.reserve(childList.size());
|
||||
for (qint32 i = 0; i < childList.size(); ++i)
|
||||
{
|
||||
const QDomElement element = childList.at(i).toElement();
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units)
|
||||
: m_units(units)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
||||
|
@ -42,7 +43,8 @@ VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, qreal min
|
|||
m_minValue(min),
|
||||
m_maxValue(max),
|
||||
m_step(step)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstartMeasurementDimension::IsValid() -> 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<qreal>
|
|||
}
|
||||
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<qreal> &exclude) -> QVector<qreal>
|
||||
auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step, const QSet<qreal> &exclude)
|
||||
-> QVector<qreal>
|
||||
{
|
||||
QVector<qreal> 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())
|
||||
|
@ -327,50 +325,58 @@ auto VAbstartMeasurementDimension::DimensionToolTip(const MeasurementDimension_p
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VXMeasurementDimension::VXMeasurementDimension(Unit units)
|
||||
: VAbstartMeasurementDimension(units)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VXMeasurementDimension::VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
||||
: VAbstartMeasurementDimension(units, min, max, step)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// VYMeasurementDimension
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VYMeasurementDimension::VYMeasurementDimension(Unit units)
|
||||
: VAbstartMeasurementDimension(units)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VYMeasurementDimension::VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
||||
: VAbstartMeasurementDimension(units, min, max, step)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// VWMeasurementDimension
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VWMeasurementDimension::VWMeasurementDimension(Unit units)
|
||||
: VAbstartMeasurementDimension(units)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VWMeasurementDimension::VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
||||
: VAbstartMeasurementDimension(units, min, max, step)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// VZMeasurementDimension
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VZMeasurementDimension::VZMeasurementDimension(Unit units)
|
||||
: VAbstartMeasurementDimension(units)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VZMeasurementDimension::VZMeasurementDimension(Unit units, qreal min, qreal max, qreal 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<qreal> const list = m_exclude.values();
|
||||
QStringList excludeList;
|
||||
excludeList.reserve(list.size());
|
||||
|
||||
for (const auto &value : list)
|
||||
{
|
||||
|
|
|
@ -680,6 +680,7 @@ auto VLayoutGenerator::MoveDetails(qreal length, const QVector<VLayoutPiece> &de
|
|||
}
|
||||
|
||||
QList<VLayoutPiece> newDetails;
|
||||
newDetails.reserve(details.size());
|
||||
for (auto d : details)
|
||||
{
|
||||
IsPortrait() ? d.Translate(0, length) : d.Translate(length, 0);
|
||||
|
|
|
@ -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<qreal> x;
|
||||
QVector<qreal> y;
|
||||
|
||||
vsizetype const n = poly.count();
|
||||
qreal s, res = 0;
|
||||
qint64 sq = 0;
|
||||
|
||||
QVector<qreal> x;
|
||||
QVector<qreal> y;
|
||||
|
||||
x.reserve(n);
|
||||
y.reserve(n);
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
x.append(poly.at(i).x());
|
||||
|
|
Loading…
Reference in New Issue
Block a user