aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-11 11:45:30 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-01-15 15:43:50 +0100
commit2b7da99972845e11fc9506b0fe2832b65d4b3ab6 (patch)
tree3811943f8e8ec65905ef5ba8fe7cddf14c908a0f
parent2511282c895d048f7eadb633219dea6f4d4d5b14 (diff)
shiboken6/Type system parser: Simplify code
Returning a reference from TypeEntry::codeSnips() allows for some simplification. Pick-to: 6.2 Task-number: PYSIDE-1766 Change-Id: I85bdd57ef3523083a95dbbafb36d8caf84282e03 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp7
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.h3
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp11
3 files changed, 10 insertions, 11 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index d46ea810e..17dc83b70 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -108,7 +108,12 @@ TypeEntry::TypeEntry(TypeEntryPrivate *d) : m_d(d)
TypeEntry::~TypeEntry() = default;
-CodeSnipList TypeEntry::codeSnips() const
+const CodeSnipList &TypeEntry::codeSnips() const
+{
+ return m_d->m_codeSnips;
+}
+
+CodeSnipList &TypeEntry::codeSnips()
{
return m_d->m_codeSnips;
}
diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h
index b81ddaaf6..db7c23d57 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.h
+++ b/sources/shiboken6/ApiExtractor/typesystem.h
@@ -205,7 +205,8 @@ public:
virtual bool isValue() const;
virtual bool isComplex() const;
- CodeSnipList codeSnips() const;
+ const CodeSnipList &codeSnips() const;
+ CodeSnipList &codeSnips();
void setCodeSnips(const CodeSnipList &codeSnips);
void addCodeSnip(const CodeSnip &codeSnip);
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index 503f2550c..af6202691 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -904,11 +904,7 @@ bool TypeSystemParser::endElement(StackElement element)
switch (m_stack.at(m_stack.size() - 2)) {
case StackElement::InjectCode:
if (m_stack.at(m_stack.size() - 3) == StackElement::Root) {
- CodeSnipList snips = top->entry->codeSnips();
- CodeSnip snip = snips.takeLast();
- snip.addTemplateInstance(m_templateInstance);
- snips.append(snip);
- top->entry->setCodeSnips(snips);
+ top->entry->codeSnips().last().addTemplateInstance(m_templateInstance);
break;
}
Q_FALLTHROUGH();
@@ -977,12 +973,9 @@ bool TypeSystemParser::characters(const String &ch)
}
if ((type & StackElement::CodeSnipMask) != 0 && stackSize > 1) {
- CodeSnipList snips;
switch (m_stack.at(stackSize - 2)) {
case StackElement::Root:
- snips = top->entry->codeSnips();
- snips.last().addCode(ch);
- top->entry->setCodeSnips(snips);
+ top->entry->codeSnips().last().addCode(ch);
break;
case StackElement::ModifyFunction:
case StackElement::AddFunction: