diff options
| author | Aurélien Brooke <aurelien@bahiasoft.fr> | 2025-07-18 12:00:31 +0200 |
|---|---|---|
| committer | Aurélien Brooke <aurelien@bahiasoft.fr> | 2025-07-21 23:15:17 +0200 |
| commit | 3babea74b2acfae64c9db2a42f33ce2c4cfad445 (patch) | |
| tree | 11076a4d4a32a816113c85ec036e7b7647cd0927 /src/tools/moc/main.cpp | |
| parent | 499edb6a98d1369cbacba8f4a14c1cb921673956 (diff) | |
moc: add lexem() functions that return QByteArrayViews
In many cases, the result of the lexem() functions is only used as a
view and is not stored. To avoid constructing thousands of temporary
QByteArray instances, introduce lexemView() and unquotedLexemView() that
return a QByteArrayView instead.
We need to carefuly remove .constData() calls on previously-QByteArrays,
because QByteArrayViews may not be NUL-terminated, so we must transfer
the size information to e.g. QString::fromLocal8bit().
This saves only about 3 % of temporary allocs but enables further
optimizations.
Change-Id: I55e389f7602ac42d3e2f83b38161286d5c17bb48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/main.cpp')
| -rw-r--r-- | src/tools/moc/main.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 3c49128476d..77f3329ac4a 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -106,7 +106,7 @@ QByteArray composePreprocessorOutput(const Symbols &symbols) { output.chop(2); else break; - output += sym.lexem().mid(1); + output += sym.lexemView().mid(1); secondlast = last; last = PP_STRING_LITERAL; continue; |
