forked from qt-creator/qt-creator
Fix wasteful loops in AndroidManager::availableQtLibs.
Detected by Krazy (values or keys iteration). Change-Id: I2ebfd4690261139ea0739bc9c00692c06064539c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -615,34 +615,38 @@ QVector<AndroidManager::Library> AndroidManager::availableQtLibsWithDependencies
|
|||||||
mapLibs[library] = Library();;
|
mapLibs[library] = Library();;
|
||||||
|
|
||||||
// clean dependencies
|
// clean dependencies
|
||||||
foreach (const QString &key, mapLibs.keys()) {
|
const LibrariesMap::Iterator lend = mapLibs.end();
|
||||||
|
for (LibrariesMap::Iterator lit = mapLibs.begin(); lit != lend; ++lit) {
|
||||||
|
Library &library = lit.value();
|
||||||
int it = 0;
|
int it = 0;
|
||||||
while (it < mapLibs[key].dependencies.size()) {
|
while (it < library.dependencies.size()) {
|
||||||
const QString &dependName = mapLibs[key].dependencies[it];
|
const QString &dependName = library.dependencies[it];
|
||||||
if (!mapLibs.keys().contains(dependName) && dependName.startsWith(QLatin1String("lib")) && dependName.endsWith(QLatin1String(".so")))
|
if (!mapLibs.contains(dependName) && dependName.startsWith(QLatin1String("lib")) && dependName.endsWith(QLatin1String(".so")))
|
||||||
mapLibs[key].dependencies.removeAt(it);
|
library.dependencies.removeAt(it);
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
if (!mapLibs[key].dependencies.size())
|
if (library.dependencies.isEmpty())
|
||||||
mapLibs[key].level = 0;
|
library.level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Library> qtLibraries;
|
QVector<Library> qtLibraries;
|
||||||
// calculate the level for every library
|
// calculate the level for every library
|
||||||
foreach (const QString &key, mapLibs.keys()) {
|
for (LibrariesMap::Iterator lit = mapLibs.begin(); lit != lend; ++lit) {
|
||||||
if (mapLibs[key].level < 0)
|
Library &library = lit.value();
|
||||||
|
const QString &key = lit.key();
|
||||||
|
if (library.level < 0)
|
||||||
setLibraryLevel(key, mapLibs);
|
setLibraryLevel(key, mapLibs);
|
||||||
|
|
||||||
if (!mapLibs[key].name.length() && key.startsWith(QLatin1String("lib")) && key.endsWith(QLatin1String(".so")))
|
if (library.name.isEmpty() && key.startsWith(QLatin1String("lib")) && key.endsWith(QLatin1String(".so")))
|
||||||
mapLibs[key].name = key.mid(3, key.length() - 6);
|
library.name = key.mid(3, key.length() - 6);
|
||||||
|
|
||||||
for (int it = 0; it < mapLibs[key].dependencies.size(); it++) {
|
for (int it = 0; it < library.dependencies.size(); it++) {
|
||||||
const QString &libName = mapLibs[key].dependencies[it];
|
const QString &libName = library.dependencies[it];
|
||||||
if (libName.startsWith(QLatin1String("lib")) && libName.endsWith(QLatin1String(".so")))
|
if (libName.startsWith(QLatin1String("lib")) && libName.endsWith(QLatin1String(".so")))
|
||||||
mapLibs[key].dependencies[it] = libName.mid(3, libName.length() - 6);
|
library.dependencies[it] = libName.mid(3, libName.length() - 6);
|
||||||
}
|
}
|
||||||
qtLibraries.push_back(mapLibs[key]);
|
qtLibraries.push_back(library);
|
||||||
}
|
}
|
||||||
qSort(qtLibraries.begin(), qtLibraries.end(), qtLibrariesLessThan);
|
qSort(qtLibraries.begin(), qtLibraries.end(), qtLibrariesLessThan);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user