From 924238ae5a3c784d907cf6f95df8eb7c3e568970 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 11 Jan 2011 16:31:05 +0300 Subject: 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 --- src/corelib/io/qprocess_unix.cpp | 16 ++++++---------- 1 file 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 #include #include -#include +#include #include #include #include @@ -163,7 +163,7 @@ public: private: QMutex mutex; - QMap children; + QHash 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::Iterator it = children.begin(); + QHash::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; } -- cgit v0.12