diff options
author | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-10-25 15:07:11 +0200 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-10-25 13:20:06 +0000 |
commit | cff2ea73dbe802de970e80025de80d9734d0f35d (patch) | |
tree | c6ab8896fbe1f5a7bb8c1863296bcf10d2dd7749 /src | |
parent | a74de6921809b42970abfdc10e8a1de461685fd9 (diff) |
[Micro]Optimize duplicate state name check
With 9 states the benchmark showed
QSet 0.00041 ms
QVector 0.00016 ms
QVLA 0.00015 ms
Change-Id: Ie2de19bd8281b7fddd9ad4246035dcd0f3483102
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/util/qquickstategroup.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index 3d8c5e0507..d8daec2f07 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -302,7 +302,8 @@ void QQuickStateGroup::componentComplete() Q_D(QQuickStateGroup); d->componentComplete = true; - QSet<QString> names; + QVarLengthArray<QString, 4> names; + names.reserve(d->states.count()); for (int ii = 0; ii < d->states.count(); ++ii) { QQuickState *state = d->states.at(ii); if (!state->isNamed()) @@ -312,7 +313,7 @@ void QQuickStateGroup::componentComplete() if (names.contains(stateName)) { qmlWarning(state->parent()) << "Found duplicate state name: " << stateName; } else { - names << stateName; + names.append(std::move(stateName)); } } |