[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp

Tor Lillqvist tml at collabora.com
Tue Mar 1 13:56:16 UTC 2016


 loolwsd/LOOLBroker.cpp |   32 +++++++++++++-------------------
 loolwsd/LOOLKit.cpp    |   32 +++++++++++++-------------------
 2 files changed, 26 insertions(+), 38 deletions(-)

New commits:
commit ec33f7b96a0fffd55a7248b084c14d00246e29f8
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 1 15:53:35 2016 +0200

    Don't use pre-increment when there is no need
    
    We are not interested in the variable being assigned an incremented
    value. Its value is not used any more. We are just interested in the
    value of the variable plus one. Using pre-increment gives the wrong
    impression.
    
    Sure, this is nit-picking.

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 74dc6e0..0269866 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -660,32 +660,32 @@ int main(int argc, char** argv)
         if (std::strstr(cmd, "--losubpath=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            loSubPath = std::string(++eq);
+            loSubPath = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--systemplate=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            sysTemplate = std::string(++eq);
+            sysTemplate = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--lotemplate=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            loTemplate = std::string(++eq);
+            loTemplate = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--childroot=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            childRoot = std::string(++eq);
+            childRoot = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--numprespawns=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            numPreSpawnedChildren = std::stoi(std::string(++eq));
+            numPreSpawnedChildren = std::stoi(std::string(eq+1));
         }
         else if (std::strstr(cmd, "--clientport=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            ClientPortNumber = std::stoll(std::string(++eq));
+            ClientPortNumber = std::stoll(std::string(eq+1));
         }
     }
 
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index bc3b567..10d6ed4 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1089,32 +1089,32 @@ int main(int argc, char** argv)
         if (std::strstr(cmd, "--childroot=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            childRoot = std::string(++eq);
+            childRoot = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--systemplate=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            sysTemplate = std::string(++eq);
+            sysTemplate = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--lotemplate=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            loTemplate = std::string(++eq);
+            loTemplate = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--losubpath=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            loSubPath = std::string(++eq);
+            loSubPath = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--pipe=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            pipe = std::string(++eq);
+            pipe = std::string(eq+1);
         }
         else if (std::strstr(cmd, "--clientport=") == cmd)
         {
             eq = std::strchr(cmd, '=');
-            ClientPortNumber = std::stoll(std::string(++eq));
+            ClientPortNumber = std::stoll(std::string(eq+1));
         }
     }
 
commit 673b08bb8106698bcce19f5d369bcdf8ee8e6a46
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 1 15:48:57 2016 +0200

    We know that there is a = in the arg as we found a string that includes it
    
    No need to to test again whether it is found. Also, std::strchr()
    works fine.

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 480c630..74dc6e0 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -656,42 +656,36 @@ int main(int argc, char** argv)
     for (int i = 0; i < argc; ++i)
     {
         char *cmd = argv[i];
-        char *eq  = nullptr;
+        char *eq;
         if (std::strstr(cmd, "--losubpath=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                loSubPath = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            loSubPath = std::string(++eq);
         }
         else if (std::strstr(cmd, "--systemplate=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                sysTemplate = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            sysTemplate = std::string(++eq);
         }
         else if (std::strstr(cmd, "--lotemplate=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                loTemplate = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            loTemplate = std::string(++eq);
         }
         else if (std::strstr(cmd, "--childroot=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                childRoot = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            childRoot = std::string(++eq);
         }
         else if (std::strstr(cmd, "--numprespawns=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                numPreSpawnedChildren = std::stoi(std::string(++eq));
+            eq = std::strchr(cmd, '=');
+            numPreSpawnedChildren = std::stoi(std::string(++eq));
         }
         else if (std::strstr(cmd, "--clientport=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                ClientPortNumber = std::stoll(std::string(++eq));
+            eq = std::strchr(cmd, '=');
+            ClientPortNumber = std::stoll(std::string(++eq));
         }
     }
 
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 892139c..bc3b567 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1084,43 +1084,37 @@ int main(int argc, char** argv)
     for (int i = 1; i < argc; ++i)
     {
         char *cmd = argv[i];
-        char *eq  = nullptr;
+        char *eq;
 
         if (std::strstr(cmd, "--childroot=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                childRoot = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            childRoot = std::string(++eq);
         }
         else if (std::strstr(cmd, "--systemplate=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                sysTemplate = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            sysTemplate = std::string(++eq);
         }
         else if (std::strstr(cmd, "--lotemplate=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                loTemplate = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            loTemplate = std::string(++eq);
         }
         else if (std::strstr(cmd, "--losubpath=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                loSubPath = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            loSubPath = std::string(++eq);
         }
         else if (std::strstr(cmd, "--pipe=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                pipe = std::string(++eq);
+            eq = std::strchr(cmd, '=');
+            pipe = std::string(++eq);
         }
         else if (std::strstr(cmd, "--clientport=") == cmd)
         {
-            eq = strchrnul(cmd, '=');
-            if (*eq)
-                ClientPortNumber = std::stoll(std::string(++eq));
+            eq = std::strchr(cmd, '=');
+            ClientPortNumber = std::stoll(std::string(++eq));
         }
     }
 


More information about the Libreoffice-commits mailing list