Use QVarLengthArray in QXcbConnection.
authorRobin Burchell <robin.burchell@collabora.com>
Wed, 7 Dec 2011 19:58:04 +0000 (20:58 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Dec 2011 23:44:00 +0000 (00:44 +0100)
There's no need in using a QList here, since it's never passed around anywhere;
the reference counting is just unnecessary overhead.

Change-Id: I92107c69f7338acc396e2ac4a69123c6a2becaed
Reviewed-by: John Brooks <john.brooks@dereferenced.net>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection.h

index 6969124..0c51cc9 100644 (file)
@@ -615,7 +615,7 @@ void QXcbEventReader::addEvent(xcb_generic_event_t *event)
     m_events << event;
 }
 
-QList<xcb_generic_event_t *> *QXcbEventReader::lock()
+QXcbEventArray *QXcbEventReader::lock()
 {
     m_mutex.lock();
 #ifndef XCB_POLL_FOR_QUEUED_EVENT
@@ -648,7 +648,7 @@ void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom a, uint id)
 
 void QXcbConnection::processXcbEvents()
 {
-    QList<xcb_generic_event_t *> *eventqueue = m_reader->lock();
+    QXcbEventArray *eventqueue = m_reader->lock();
 
     for(int i = 0; i < eventqueue->size(); ++i) {
         xcb_generic_event_t *event = eventqueue->at(i);
@@ -711,7 +711,7 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *
 
 xcb_generic_event_t *QXcbConnection::checkEvent(int type)
 {
-    QList<xcb_generic_event_t *> *eventqueue = m_reader->lock();
+    QXcbEventArray *eventqueue = m_reader->lock();
 
     for (int i = 0; i < eventqueue->size(); ++i) {
         xcb_generic_event_t *event = eventqueue->at(i);
index ebe95c0..878d41a 100644 (file)
@@ -50,6 +50,7 @@
 #include <QObject>
 #include <QThread>
 #include <QVector>
+#include <QVarLengthArray>
 
 #ifdef XCB_USE_XINPUT2_MAEMO
 struct XInput2Data;
@@ -249,6 +250,8 @@ namespace QXcbAtom {
     };
 }
 
+typedef QVarLengthArray<xcb_generic_event_t *, 64> QXcbEventArray;
+
 class QXcbConnection;
 class QXcbEventReader : public QThread
 {
@@ -263,7 +266,7 @@ public:
     void run();
 #endif
 
-    QList<xcb_generic_event_t *> *lock();
+    QXcbEventArray *lock();
     void unlock();
 
 signals:
@@ -273,7 +276,7 @@ private:
     void addEvent(xcb_generic_event_t *event);
 
     QMutex m_mutex;
-    QList<xcb_generic_event_t *> m_events;
+    QXcbEventArray m_events;
     QXcbConnection *m_connection;
 };
 
@@ -427,7 +430,7 @@ private:
 template<typename T>
 xcb_generic_event_t *QXcbConnection::checkEvent(const T &checker)
 {
-    QList<xcb_generic_event_t *> *eventqueue = m_reader->lock();
+    QXcbEventArray *eventqueue = m_reader->lock();
 
     for (int i = 0; i < eventqueue->size(); ++i) {
         xcb_generic_event_t *event = eventqueue->at(i);