diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-01-11 13:31:05 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-11 14:55:07 (GMT) |
commit | 924238ae5a3c784d907cf6f95df8eb7c3e568970 (patch) | |
tree | 651d817b76ab56936aa8b6ede2763d6efdba905a /src | |
parent | 3e865c9f80bd3666673158e8a1664e7405fe9364 (diff) | |
download | Qt-924238ae5a3c784d907cf6f95df8eb7c3e568970.zip Qt-924238ae5a3c784d907cf6f95df8eb7c3e568970.tar.gz Qt-924238ae5a3c784d907cf6f95df8eb7c3e568970.tar.bz2 |
QProcessManager: minor optimization
QHash is slightly faster than QMap and should be preferred where
the key order has no meaning;
take() is faster than value() + remove()
Reviewed-by: Olivier Goffart
Merge-request: 1017
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 299280e..d4cf3f5 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -95,7 +95,7 @@ QT_END_NAMESPACE #include <qfile.h> #include <qfileinfo.h> #include <qlist.h> -#include <qmap.h> +#include <qhash.h> #include <qmutex.h> #include <qsemaphore.h> #include <qsocketnotifier.h> @@ -163,7 +163,7 @@ public: private: QMutex mutex; - QMap<int, QProcessInfo *> children; + QHash<int, QProcessInfo *> children; }; @@ -281,7 +281,7 @@ void QProcessManager::catchDeadChildren() // try to catch all children whose pid we have registered, and whose // deathPipe is still valid (i.e, we have not already notified it). - QMap<int, QProcessInfo *>::Iterator it = children.begin(); + QHash<int, QProcessInfo *>::Iterator it = children.begin(); while (it != children.end()) { // notify all children that they may have died. they need to run // waitpid() in their own thread. @@ -320,15 +320,11 @@ void QProcessManager::remove(QProcess *process) QMutexLocker locker(&mutex); int serial = process->d_func()->serial; - QProcessInfo *info = children.value(serial); - if (!info) - return; - + QProcessInfo *info = children.take(serial); #if defined (QPROCESS_DEBUG) - qDebug() << "QProcessManager::remove() removing pid" << info->pid << "process" << info->process; + if (info) + qDebug() << "QProcessManager::remove() removing pid" << info->pid << "process" << info->process; #endif - - children.remove(serial); delete info; } |