QLoggingRegistry: optimize updateRules()

... by not creating three temporary QVectors just to concatenate them.

There's no QVectorBuilder, so what works well with QStrings doesn't
work well at all with QVectors. The chaining of op+ causes three
temporary QVectors to be created and thrown away.

Instead, use clear() (which preserves the vector's capacity these days),
followed by four op+=.

Change-Id: I300bd35544ea41037d28db0f48f210c33c826b85
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
This commit is contained in:
Marc Mutz 2017-02-06 21:46:11 +01:00
parent 3de596a321
commit 1401225330

View File

@ -365,7 +365,12 @@ void QLoggingRegistry::setApiRules(const QString &content)
*/
void QLoggingRegistry::updateRules()
{
rules = qtConfigRules + configRules + apiRules + envRules;
rules.clear();
rules.reserve(qtConfigRules.size() + configRules.size() + apiRules.size() + envRules.size()),
rules += qtConfigRules;
rules += configRules;
rules += apiRules;
rules += envRules;
for (auto it = categories.keyBegin(), end = categories.keyEnd(); it != end; ++it)
(*categoryFilter)(*it);