diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-04-28 10:53:14 +0200 |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-05-10 12:54:52 +0200 |
commit | 9ff8d1c34a74bd852a7eb2016b46ab2904340b05 (patch) | |
tree | 923330e5d529a8b616c4d4ecbf6c42d48f14a5b9 /src/corelib/io/qprocess.cpp | |
parent | 299d10549f5aff50cd6211eb3d3e58c17f13be81 (diff) |
make QProcessEnvironment on Unix cache converted variable names
the converted keys also cache their hash, as they are used only for the
purpose of looking up in a qhash.
Reviewed-by: thiago
Reviewed-by: dt
(cherry picked from commit 18f1613aa8ece72d24ac10e28f06e3db1d8ce400)
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index ffd5ff0ff8..80e0b0f36f 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -202,12 +202,19 @@ QStringList QProcessEnvironmentPrivate::keys() const return result; } -void QProcessEnvironmentPrivate::insert(const Hash &h) +void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other) { - Hash::ConstIterator it = h.constBegin(), - end = h.constEnd(); + Hash::ConstIterator it = other.hash.constBegin(), + end = other.hash.constEnd(); for ( ; it != end; ++it) hash.insert(it.key(), it.value()); + +#ifdef Q_OS_UNIX + QHash<QString, Key>::ConstIterator nit = other.nameMap.constBegin(), + nend = other.nameMap.constEnd(); + for ( ; nit != nend; ++nit) + nameMap.insert(nit.key(), nit.value()); +#endif } /*! @@ -288,6 +295,8 @@ void QProcessEnvironment::clear() { if (d) d->hash.clear(); + // Unix: Don't clear d->nameMap, as the environment is likely to be + // re-populated with the same keys again. } /*! @@ -409,7 +418,7 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e) return; // d detaches from null - d->insert(e.d->hash); + d->insert(*e.d); } void QProcessPrivate::Channel::clear() |