From 3b60eaff08f7ed14398160592ef0c174ecf1df5a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 15 Aug 2017 11:38:36 +0300 Subject: [PATCH] List to speed up reading a template by many pieces. --HG-- branch : feature --- src/libs/ifc/xml/vabstractpattern.cpp | 16 ++++++++++++---- src/libs/ifc/xml/vabstractpattern.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 4ef4e0585..a987db4eb 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -194,6 +194,7 @@ const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline"); const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"); QHash VAbstractPattern::tools = QHash(); +QVector VAbstractPattern::patternLabelLines = QVector(); namespace { @@ -1381,17 +1382,24 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector QDomElement tag = CheckTagExists(TagPatternLabel); RemoveAllChildren(tag); SetLabelTemplate(tag, lines); + patternLabelLines = lines; } //--------------------------------------------------------------------------------------------------------------------- QVector VAbstractPattern::GetPatternLabelTemplate() const { - const QDomNodeList list = elementsByTagName(TagPatternLabel); - if (list.isEmpty()) + if (patternLabelLines.isEmpty()) { - return QVector(); + const QDomNodeList list = elementsByTagName(TagPatternLabel); + if (list.isEmpty()) + { + return QVector(); + } + + patternLabelLines = GetLabelTemplate(list.at(0).toElement()); } - return GetLabelTemplate(list.at(0).toElement()); + + return patternLabelLines; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index bc81b2ea8..33a4e9647 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -387,6 +387,8 @@ protected: /** @brief tools list with pointer on tools. */ static QHash tools; + /** @brief patternLabelLines list to speed up reading a template by many pieces. */ + static QVector patternLabelLines; static void ToolExists(const quint32 &id); static VPiecePath ParsePathNodes(const QDomElement &domElement);