diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2025-01-30 10:15:24 +0100 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2025-02-18 20:02:03 +0100 |
| commit | e338bbed44d09c08b7ca047ff0914ed01d3917fd (patch) | |
| tree | bae1b6f2eb056cbe97a9553b40c0834933bbf072 /src/qmlcompiler/qqmljsutils.cpp | |
| parent | fbed221670bb3fa8ea5b16a02c91806425467b79 (diff) | |
qqmljsutils: improve didYouMean performance
didYouMean eats up a lot of time in the profiler when imports can't be
found, so its not really a "performance fix". But it makes qmllint
faster on files that have a typo in its imports for example.
Swapping QList with QVarLengthArray makes the runtime of
tst_qmllint_benchmark:onlyQdsLintPlugin on
qtdesign-studio/examples/DesignEffectsDemo/content/Gallery.ui.qml go
from 150ms to 125ms when the QtDesign studio modules import paths are
missing. It seems that QVarLengthArray does less allocations than QList,
probably because of the std::swap.
It seemed that std::vector had similar performance to QVarLengthArray,
up to some ms.
Task-number: QTBUG-133349
Change-Id: I3facc8f194da6eaf1aebbce91292bf9b164b740e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsutils.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsutils.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljsutils.cpp b/src/qmlcompiler/qqmljsutils.cpp index ad8a14944f..37e16af090 100644 --- a/src/qmlcompiler/qqmljsutils.cpp +++ b/src/qmlcompiler/qqmljsutils.cpp @@ -123,8 +123,8 @@ std::optional<QQmlJSFixSuggestion> QQmlJSUtils::didYouMean(const QString &userIn * Roughly based on * https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_matrix_rows. */ - QList<int> v0(candidate.size() + 1); - QList<int> v1(candidate.size() + 1); + QVarLengthArray<int> v0(candidate.size() + 1); + QVarLengthArray<int> v1(candidate.size() + 1); std::iota(v0.begin(), v0.end(), 0); |
