summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-15 05:18:26 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-15 05:21:34 (GMT)
commit4fb59e0a8d40083f545dd43a370bd6d7b7b4cd35 (patch)
tree54cdfa22619e446ed349e8c1486e6cea3e64c707
parent4089401868dd62972a750c3e668a2998071de97c (diff)
downloadQt-4fb59e0a8d40083f545dd43a370bd6d7b7b4cd35.zip
Qt-4fb59e0a8d40083f545dd43a370bd6d7b7b4cd35.tar.gz
Qt-4fb59e0a8d40083f545dd43a370bd6d7b7b4cd35.tar.bz2
Optimise iterations over QHash.
-rw-r--r--src/network/bearer/qbearerengine.cpp25
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp20
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp30
3 files changed, 41 insertions, 34 deletions
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
index bd2ca6c..58d64f2 100644
--- a/src/network/bearer/qbearerengine.cpp
+++ b/src/network/bearer/qbearerengine.cpp
@@ -50,22 +50,23 @@ QBearerEngine::QBearerEngine(QObject *parent)
QBearerEngine::~QBearerEngine()
{
- foreach (const QString &oldIface, snapConfigurations.keys()) {
- QNetworkConfigurationPrivatePointer priv = snapConfigurations.take(oldIface);
- priv->isValid = false;
- priv->id.clear();
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
+ for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
+ it.value()->isValid = false;
+ it.value()->id.clear();
}
- foreach (const QString &oldIface, accessPointConfigurations.keys()) {
- QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.take(oldIface);
- priv->isValid = false;
- priv->id.clear();
+ for (it = accessPointConfigurations.begin(), end = accessPointConfigurations.end();
+ it != end; ++it) {
+ it.value()->isValid = false;
+ it.value()->id.clear();
}
- foreach (const QString &oldIface, userChoiceConfigurations.keys()) {
- QNetworkConfigurationPrivatePointer priv = userChoiceConfigurations.take(oldIface);
- priv->isValid = false;
- priv->id.clear();
+ for (it = userChoiceConfigurations.begin(), end = userChoiceConfigurations.end();
+ it != end; ++it) {
+ it.value()->isValid = false;
+ it.value()->id.clear();
}
}
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 2e37e01..f54a985 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -235,25 +235,25 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe
QNetworkConfigurationManagerPrivate* conPriv = connManager();
foreach (QBearerEngine *engine, conPriv->sessionEngines) {
- QStringList cpsIdents = engine->accessPointConfigurations.keys();
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
//find all InternetAccessPoints
- foreach (const QString &ii, cpsIdents) {
- QNetworkConfigurationPrivatePointer p = engine->accessPointConfigurations.value(ii);
- if ((p->state & filter) == filter) {
+ for (it = engine->accessPointConfigurations.begin(),
+ end = engine->accessPointConfigurations.end(); it != end; ++it) {
+ if ((it.value()->state & filter) == filter) {
QNetworkConfiguration pt;
- pt.d = engine->accessPointConfigurations.value(ii);
+ pt.d = it.value();
result << pt;
}
}
//find all service networks
- cpsIdents = engine->snapConfigurations.keys();
- foreach (const QString &ii, cpsIdents) {
- QNetworkConfigurationPrivatePointer p = engine->snapConfigurations.value(ii);
- if ((p->state & filter) == filter) {
+ for (it = engine->snapConfigurations.begin(),
+ end = engine->snapConfigurations.end(); it != end; ++it) {
+ if ((it.value()->state & filter) == filter) {
QNetworkConfiguration pt;
- pt.d = engine->snapConfigurations.value(ii);
+ pt.d = it.value();
result << pt;
}
}
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 01a85a5..b7a30b8 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -244,16 +244,19 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
QNetworkConfigurationPrivatePointer firstDiscovered;
foreach (QBearerEngine *engine, sessionEngines) {
- foreach (const QString &id, engine->snapConfigurations.keys()) {
- QNetworkConfigurationPrivatePointer ptr = engine->snapConfigurations.value(id);
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
- if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ for (it = engine->snapConfigurations.begin(), end = engine->snapConfigurations.end();
+ it != end; ++it) {
+ if ((it.value()->state & QNetworkConfiguration::Active) ==
+ QNetworkConfiguration::Active) {
QNetworkConfiguration config;
- config.d = ptr;
+ config.d = it.value();
return config;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ } else if ((it.value()->state & QNetworkConfiguration::Discovered) ==
QNetworkConfiguration::Discovered) {
- firstDiscovered = ptr;
+ firstDiscovered = it.value();
}
}
}
@@ -269,16 +272,19 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
firstDiscovered.reset();
foreach (QBearerEngine *engine, sessionEngines) {
- foreach (const QString &id, engine->accessPointConfigurations.keys()) {
- QNetworkConfigurationPrivatePointer ptr = engine->accessPointConfigurations.value(id);
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
+ QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
- if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ for (it = engine->accessPointConfigurations.begin(),
+ end = engine->accessPointConfigurations.end(); it != end; ++it) {
+ if ((it.value()->state & QNetworkConfiguration::Active) ==
+ QNetworkConfiguration::Active) {
QNetworkConfiguration config;
- config.d = ptr;
+ config.d = it.value();
return config;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ } else if ((it.value()->state & QNetworkConfiguration::Discovered) ==
QNetworkConfiguration::Discovered) {
- firstDiscovered = ptr;
+ firstDiscovered = it.value();
}
}
}