[Libreoffice-commits] online.git: Branch 'private/tml/cancellation' - loolwsd/LoadTest.cpp loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp

Tor Lillqvist tml at collabora.com
Tue Jun 9 08:25:12 PDT 2015


 loolwsd/LOOLSession.cpp |    4 +---
 loolwsd/LOOLWSD.cpp     |   12 ++++--------
 loolwsd/LoadTest.cpp    |    3 +--
 3 files changed, 6 insertions(+), 13 deletions(-)

New commits:
commit 12e0a346ca0e1ae11b5473394e506e7df20a9457
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Jun 9 18:22:09 2015 +0300

    Don't bother with storing a ref to Application::instance() in a variable in some places

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 9da6244..2b2d9bb 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -663,12 +663,10 @@ ChildProcessSession::~ChildProcessSession()
 
 bool ChildProcessSession::handleInput(const char *buffer, int length)
 {
-    Application& app = Application::instance();
-
     std::string firstLine = getFirstLine(buffer, length);
     StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
-    app.logger().information(Util::logPrefix() + "Input: " + getAbbreviatedMessage(buffer, length));
+    Application::instance().logger().information(Util::logPrefix() + "Input: " + getAbbreviatedMessage(buffer, length));
 
     if (tokens[0] == "load")
     {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 7bbe69c..f654612 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -169,8 +169,6 @@ public:
             return;
         }
 
-        Application& app = Application::instance();
-
         tsqueue<std::string> queue;
         Thread queueHandlerThread;
         QueueHandler handler(queue);
@@ -258,7 +256,7 @@ public:
             }
             catch (WebSocketException& exc)
             {
-                app.logger().error(Util::logPrefix() + "WebSocketException: " + exc.message());
+                Application::instance().logger().error(Util::logPrefix() + "WebSocketException: " + exc.message());
                 switch (exc.code())
                 {
                 case WebSocket::WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION:
@@ -276,7 +274,7 @@ public:
         }
         catch (IOException& exc)
         {
-            app.logger().error(Util::logPrefix() + "IOException: " + exc.message());
+            Application::instance().logger().error(Util::logPrefix() + "IOException: " + exc.message());
         }
         queue.clear();
         queue.put("eof");
@@ -293,7 +291,6 @@ public:
 
     HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) override
     {
-        Application& app = Application::instance();
         std::string line = (Util::logPrefix() + "Request from " +
                             request.clientAddress().toString() + ": " +
                             request.getMethod() + " " +
@@ -305,7 +302,7 @@ public:
             line += " / " + it->first + ": " + it->second;
         }
 
-        app.logger().information(line);
+        Application::instance().logger().information(line);
         return new WebSocketRequestHandler();
     }
 };
@@ -322,7 +319,6 @@ public:
     {
         int flags;
         int n;
-        Application& app = Application::instance();
         _ws.setReceiveTimeout(0);
         try
         {
@@ -343,7 +339,7 @@ public:
         }
         catch (WebSocketException& exc)
         {
-            app.logger().error(Util::logPrefix() + "WebSocketException: " + exc.message());
+            Application::instance().logger().error(Util::logPrefix() + "WebSocketException: " + exc.message());
             _ws.close();
         }
     }
diff --git a/loolwsd/LoadTest.cpp b/loolwsd/LoadTest.cpp
index c03d581..b146ed2 100644
--- a/loolwsd/LoadTest.cpp
+++ b/loolwsd/LoadTest.cpp
@@ -86,7 +86,6 @@ public:
         int flags;
         int n;
         int tileCount = 0;
-        Application& app = Application::instance();
         try
         {
             do
@@ -135,7 +134,7 @@ public:
         }
         catch (WebSocketException& exc)
         {
-            app.logger().error("WebSocketException: " + exc.message());
+            Application::instance().logger().error("WebSocketException: " + exc.message());
             _ws.close();
         }
         std::cout << Util::logPrefix() << "Got " << tileCount << " tiles" << std::endl;


More information about the Libreoffice-commits mailing list