summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-13 14:54:14 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-21 13:03:07 (GMT)
commit48d4baca5becf0966ad02f3f316cd9894ef6d5c3 (patch)
treef45d3877010d2b106887095ba4265ca591779eba
parent0375a941dcd45b71a9397dbd405c9c055ab9a81a (diff)
downloadQt-48d4baca5becf0966ad02f3f316cd9894ef6d5c3.zip
Qt-48d4baca5becf0966ad02f3f316cd9894ef6d5c3.tar.gz
Qt-48d4baca5becf0966ad02f3f316cd9894ef6d5c3.tar.bz2
Execute some small performance improvements in QProcessEnvironment
If d == 0, then we know we have no items. Therefore, removing or clearing is an idempotent action. So instead of detaching, leave d == 0. In the search function, avoid converting the defaultValue to the internal representation.
-rw-r--r--src/corelib/io/qprocess.cpp13
-rw-r--r--src/corelib/io/qprocess_p.h3
2 files changed, 11 insertions, 5 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 7c13bf0..733887a 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -293,7 +293,8 @@ bool QProcessEnvironment::isEmpty() const
*/
void QProcessEnvironment::clear()
{
- d->hash.clear();
+ if (d)
+ d->hash.clear();
}
/*!
@@ -345,7 +346,8 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
*/
void QProcessEnvironment::remove(const QString &name)
{
- d->hash.remove(prepareName(name));
+ if (d)
+ d->hash.remove(prepareName(name));
}
/*!
@@ -364,8 +366,11 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d)
return defaultValue;
- QProcessEnvironmentPrivate::Unit result = d->hash.value(prepareName(name), prepareValue(defaultValue));
- return valueToString(result);
+ QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(prepareName(name));
+ if (it == d->hash.constEnd())
+ return defaultValue;
+
+ return valueToString(it.value());
}
/*!
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 1e2979b..b581e91 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -86,7 +86,8 @@ public:
#else
typedef QByteArray Unit;
#endif
- QHash<Unit, Unit> hash;
+ typedef QHash<Unit, Unit> Hash;
+ Hash hash;
static QProcessEnvironment fromList(const QStringList &list);
QStringList toList() const;