summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_unix.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-01-11 16:31:05 +0300
committerOlivier Goffart <olivier.goffart@nokia.com>2011-01-11 15:55:07 +0100
commit924238ae5a3c784d907cf6f95df8eb7c3e568970 (patch)
tree651d817b76ab56936aa8b6ede2763d6efdba905a /src/corelib/io/qprocess_unix.cpp
parent3e865c9f80bd3666673158e8a1664e7405fe9364 (diff)
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/corelib/io/qprocess_unix.cpp')
-rw-r--r--src/corelib/io/qprocess_unix.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 299280e109..d4cf3f52a8 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;
}