Refactoring.

Fix places defining containers inside loops.
This commit is contained in:
Roman Telezhynskyi 2024-04-17 12:53:23 +03:00
parent 8063645cf6
commit afd948b330
2 changed files with 9 additions and 3 deletions

View File

@ -2612,6 +2612,8 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
QDomElement const groups = CreateGroups(patternPieceName); QDomElement const groups = CreateGroups(patternPieceName);
if (not groups.isNull()) if (not groups.isNull())
{ {
QVector<QPair<quint32, quint32>> items;
QDomNode domNode = groups.firstChild(); QDomNode domNode = groups.firstChild();
while (not domNode.isNull()) while (not domNode.isNull())
{ {
@ -2630,7 +2632,7 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags)); groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR); groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR);
QVector<QPair<quint32, quint32>> items; items.resize(0);
const QDomNodeList nodeList = group.childNodes(); const QDomNodeList nodeList = group.childNodes();
const qint32 num = nodeList.size(); const qint32 num = nodeList.size();

View File

@ -1186,13 +1186,15 @@ void VPatternConverter::ParseModelingToV0_2_4(const QDomElement &modeling)
// TODO. Delete if minimal supported version is 0.2.4 // TODO. Delete if minimal supported version is 0.2.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code."); Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code.");
QVector<quint32> children;
QDomElement node = modeling.firstChild().toElement(); QDomElement node = modeling.firstChild().toElement();
while (not node.isNull()) while (not node.isNull())
{ {
if (node.tagName() == *strTools) if (node.tagName() == *strTools)
{ {
const quint32 toolId = node.attribute(*strId).toUInt(); const quint32 toolId = node.attribute(*strId).toUInt();
QVector<quint32> children; children.resize(0);
QDomElement childNode = node.nextSibling().toElement(); QDomElement childNode = node.nextSibling().toElement();
while (not childNode.isNull()) while (not childNode.isNull())
{ {
@ -2221,6 +2223,8 @@ void VPatternConverter::TagUnionDetailsToV0_4_0()
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
QVector<QDomElement> nodes;
const QDomNodeList list = elementsByTagName(*strTools); const QDomNodeList list = elementsByTagName(*strTools);
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
@ -2230,7 +2234,7 @@ void VPatternConverter::TagUnionDetailsToV0_4_0()
{ {
const QStringList tags = QStringList() << *strDet << *strChildren; const QStringList tags = QStringList() << *strDet << *strChildren;
QVector<QDomElement> nodes; nodes.resize(0);
QDomElement tagChildrenNodes = createElement(*strChildren); QDomElement tagChildrenNodes = createElement(*strChildren);
const QDomNodeList childList = toolDOM.childNodes(); const QDomNodeList childList = toolDOM.childNodes();