diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-29 09:26:05 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-29 10:35:14 +0000 |
commit | 2d197c6c1226cba097a5a0a100776c62a37472a7 (patch) | |
tree | f9ab2c563bd9c11c87d6ca11e93057a4d59a4593 /src/core/aspects | |
parent | e484d72a00225ffd71c5dc356f66e2d73c06b823 (diff) |
Optimize string handling in QAspectEngine::executeCommand()
Instead of building up a QStringList and then join()ing,
build up the QString directly, taking advantage of the
fact that we know there is always one line, so the joiner
can be unconditionally prepended to each following line.
Saves memory allocations, while the text size is virtually
unchanged.
Change-Id: I9ce4fbf22fbc20bbb045571145d84d046907f9d4
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/aspects')
-rw-r--r-- | src/core/aspects/qaspectengine.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp index 9fca7b985..2045d623b 100644 --- a/src/core/aspects/qaspectengine.cpp +++ b/src/core/aspects/qaspectengine.cpp @@ -212,16 +212,16 @@ QVariant QAspectEngine::executeCommand(const QString &command) if (d->m_aspects.isEmpty()) return QLatin1Literal("No loaded aspect"); - QStringList reply; - reply << QLatin1Literal("Loaded aspects:"); + QString reply; + reply += QLatin1String("Loaded aspects:"); for (QAbstractAspect *aspect : qAsConst(d->m_aspects)) { const QString name = d->m_factory.aspectName(aspect); if (!name.isEmpty()) - reply << (QLatin1Literal(" * ") + name); + reply += QLatin1String("\n * ") + name; else - reply << QLatin1Literal(" * <unnamed>"); + reply += QLatin1String("\n * <unnamed>"); } - return reply.join(QLatin1Char('\n')); + return reply; } QStringList args = command.split(QLatin1Char(' ')); |