summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
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 /src/corelib/io/qprocess.cpp
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.
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp13
1 files changed, 9 insertions, 4 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());
}
/*!