]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
SocketApi::slotReadSocket: Small optimizations
authorJocelyn Turcotte <jturcotte@woboq.com>
Wed, 11 Jan 2017 17:31:08 +0000 (18:31 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Wed, 18 Jan 2017 11:15:52 +0000 (12:15 +0100)
- Use the looked-up method index also for the invocation
- Do the method name concatenation already on QByteArray since we'll
  convert anyway
- Use staticMetaObject instead of metaObject()

src/gui/socketapi.cpp

index 8ce0c8cc6ea61c00f71e3f192a80a7429b3879fd..9396fe81d1375080b4df57cf281cbf7a1febe4ec 100644 (file)
@@ -175,15 +175,13 @@ void SocketApi::slotReadSocket()
         // make sure that the path will match, especially on OS X.
         QString line = QString::fromUtf8(socket->readLine()).normalized(QString::NormalizationForm_C);
         line.chop(1); // remove the '\n'
-        QString command = line.split(":").value(0);
-        QString function = QString(QLatin1String("command_")).append(command);
-
-        QString functionWithArguments = function + QLatin1String("(QString,QIODevice*)");
-        int indexOfMethod = this->metaObject()->indexOfMethod(functionWithArguments.toAscii());
+        QByteArray command = line.split(":").value(0).toAscii();
+        QByteArray functionWithArguments = "command_" + command + "(QString,SocketListener*)";
+        int indexOfMethod = staticMetaObject.indexOfMethod(functionWithArguments);
 
         QString argument = line.remove(0, command.length()+1);
         if(indexOfMethod != -1) {
-            QMetaObject::invokeMethod(this, function.toAscii(), Q_ARG(QString, argument), Q_ARG(QIODevice*, socket));
+            staticMetaObject.method(indexOfMethod).invoke(this, Q_ARG(QString, argument), Q_ARG(QIODevice*, socket));
         } else {
             DEBUG << "The command is not supported by this version of the client:" << command << "with argument:" << argument;
         }