diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-10-10 13:43:25 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-10-11 13:55:28 +0000 |
commit | 05b2377d2f20b451e8328b1c5a1adf13ec01ebf3 (patch) | |
tree | 41d18467fdee22a11b21060b537ad3272895387d /src | |
parent | fb3a62df26331d696e1e97b3703f49199d714d08 (diff) |
Optimize keeping component reference count in InstallerCalculator
To avoid constructing possibly large temporary QStringList objects,
return the value by modifiable reference when accessing the
m_referenceCount container.
Task-number: QTIFW-2790
Change-Id: Ieb2619624cfbf12561dbec25b966bb7dbae5d29c
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/installercalculator.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index f71a35858..48c90621b 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -229,13 +229,11 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q if (m_toInstallComponentIds.contains(dependencyComponentName) && m_referenceCount.contains(dependencyComponentName)) { if (!component->autoDependencies().contains(dependencyComponentName)) { - QStringList value = m_referenceCount.value(dependencyComponentName); + QStringList &value = m_referenceCount[dependencyComponentName]; if (value.contains(component->name())) { value.removeOne(component->name()); if (value.isEmpty()) m_referenceCount.remove(dependencyComponentName); - else - m_referenceCount.insert(dependencyComponentName, value); } } } @@ -262,11 +260,8 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q } m_visitedComponents[component].insert(dependencyComponent); } - if (!component->autoDependencies().contains(dependencyComponentName)) { - QStringList value = m_referenceCount.value(dependencyComponentName, QStringList()); - value << component->name(); - m_referenceCount.insert(dependencyComponentName, value); - } + if (!component->autoDependencies().contains(dependencyComponentName)) + m_referenceCount[dependencyComponentName] << component->name(); insertInstallReason(dependencyComponent, InstallerCalculator::Dependent, component->name()); if (!appendComponentToInstall(dependencyComponent, requiredDependencyVersion, revertFromInstall)) |