diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-01-11 11:45:30 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-15 16:10:21 +0000 |
commit | a5ed4422e5cfd7a63a712d6a32220c6922c3d4c8 (patch) | |
tree | 9e3d694322e6a0dd75a5b623fa2fbaeb286f71d0 | |
parent | 503b90cf87bec4f342347eee637a9a86e3c5f694 (diff) |
shiboken6/Type system parser: Simplify code
Returning a reference from TypeEntry::codeSnips() allows for some
simplification.
Task-number: PYSIDE-1766
Change-Id: I85bdd57ef3523083a95dbbafb36d8caf84282e03
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 2b7da99972845e11fc9506b0fe2832b65d4b3ab6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystem.cpp | 7 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystem.h | 3 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystemparser.cpp | 11 |
3 files changed, 10 insertions, 11 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp index 5d1a8c8b5..c059251da 100644 --- a/sources/shiboken6/ApiExtractor/typesystem.cpp +++ b/sources/shiboken6/ApiExtractor/typesystem.cpp @@ -122,7 +122,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 63244f024..8d766322a 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 6d9b75fd1..bfa00643e 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: |