diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-24 13:15:22 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-27 11:44:51 +0100 |
commit | 23f0761d22bd972b046614fa173b29555b2d2047 (patch) | |
tree | 2ece4ed6b93db6f4134225a968cdcbd2671af971 /src/qdoc/qmlcodeparser.h | |
parent | 2a3f531028e8c59a745d3fb90aecbed18cd759dd (diff) | |
download | qttools-23f0761d22bd972b046614fa173b29555b2d2047.tar.gz |
QDoc: Remove `QmlCodeParser::m_lexer`
As part of producing a documentation set, QDoc parses a series of
user-defined input source files in various languages to extract the
user-provided documentation and certain source-code level elements.
For QML source files, the `QmlCodeParser` class is used, taking care of
reading the QML code and build an internal representation for some of
its elements.
`QmlCodeParser` uses the `QQmlJs` parsing api to do so.
As part of using the `QQmlJs` parsing api, `QmlCodeParser` has to build
a `QQmlJs::Engine`, `QQmlJs::Lexer` and `QQmlJsEngine::Parser`.
Currently, `QmlCodeParser` stores all those elements as instance
members. For example, for the `QQmlJs::Lexer` instance, a member
variable `m_lexer` is used as storage.
Supposedly, this is intended as a way to avoid building the three
elements more than once.
Building a `QQmlJs::Lexer` more than once does not provide any
meaningful overhead, moreover not in the code path where it is used.
Furthermore, `m_lexer` is used only once, in
`QmlCodeParser::parseSourceFile`, the entry point for parsing a QML
source file.
Hence, to reduce the scope of `m_lexer` and avoid requiring an
out-of-scope initialization for it, `m_lexer` is now removed in favor of
an local instance in `QmlCodeParser::parseSourceFile`.
The initialization and deletion of `m_lexer` in
`QmlCodeParser::initializeParser` and `QmlCodeParser::terminateParser`
was removed as a consequence of the removal of the member.
Some comments that mentioned the initialization or deletion of the lexer
were modified to represent the modified code.
Change-Id: I32d38e7883273ab83745eb1f34d183fd5ecca19a
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/qmlcodeparser.h')
-rw-r--r-- | src/qdoc/qmlcodeparser.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/src/qdoc/qmlcodeparser.h b/src/qdoc/qmlcodeparser.h index 91ee64858..bbf2a1545 100644 --- a/src/qdoc/qmlcodeparser.h +++ b/src/qdoc/qmlcodeparser.h @@ -34,7 +34,6 @@ public: private: QQmlJS::Engine m_engine {}; - QQmlJS::Lexer *m_lexer { nullptr }; QQmlJS::Parser *m_parser { nullptr }; }; |