[Libreoffice-commits] online.git: loolwsd/AdminModel.cpp loolwsd/AdminModel.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri Nov 25 03:47:50 UTC 2016


 loolwsd/AdminModel.cpp |   19 +++++++++++--------
 loolwsd/AdminModel.hpp |   14 +++++---------
 2 files changed, 16 insertions(+), 17 deletions(-)

New commits:
commit 96a1a796c4a6daf4654e924a83fe225ee485a77d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Nov 23 22:42:27 2016 -0500

    loolwsd: AdminModel cleanup
    
    Change-Id: I2f73b0063b905b641e14110af6421191bc9b2533
    Reviewed-on: https://gerrit.libreoffice.org/31183
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/AdminModel.cpp b/loolwsd/AdminModel.cpp
index 62d4ab7..6de25e4 100644
--- a/loolwsd/AdminModel.cpp
+++ b/loolwsd/AdminModel.cpp
@@ -244,6 +244,7 @@ void AdminModel::addDocument(const std::string& docKey, Poco::Process::PID pid,
 {
     const auto ret = _documents.emplace(docKey, Document(docKey, pid, filename));
     ret.first->second.addView(sessionId);
+    LOG_DBG("Added admin document [" + docKey + "].");
 
     // Notify the subscribers
     const unsigned memUsage = Util::getMemoryUsage(pid);
@@ -285,16 +286,18 @@ void AdminModel::removeDocument(const std::string& docKey)
     auto docIt = _documents.find(docKey);
     if (docIt != _documents.end())
     {
+        std::ostringstream oss;
+        oss << "rmdoc "
+            << docIt->second.getPid() << ' ';
+        const std::string msg = oss.str();
+
         for (const auto& pair : docIt->second.getViews())
         {
             // Notify the subscribers
-            std::ostringstream oss;
-            oss << "rmdoc "
-                << docIt->second.getPid() << ' '
-                << pair.first;
-            notify(oss.str());
+            notify(msg + pair.first);
         }
 
+        LOG_DBG("Removed admin document [" + docKey + "].");
         _documents.erase(docIt);
     }
 }
@@ -302,7 +305,7 @@ void AdminModel::removeDocument(const std::string& docKey)
 std::string AdminModel::getMemStats()
 {
     std::ostringstream oss;
-    for (auto& i: _memStats)
+    for (const auto& i: _memStats)
     {
         oss << i << ',';
     }
@@ -313,7 +316,7 @@ std::string AdminModel::getMemStats()
 std::string AdminModel::getCpuStats()
 {
     std::ostringstream oss;
-    for (auto& i: _cpuStats)
+    for (const auto& i: _cpuStats)
     {
         oss << i << ',';
     }
@@ -324,7 +327,7 @@ std::string AdminModel::getCpuStats()
 unsigned AdminModel::getTotalActiveViews()
 {
     unsigned nTotalViews = 0;
-    for (auto& it: _documents)
+    for (const auto& it: _documents)
     {
         if (!it.second.isExpired())
         {
diff --git a/loolwsd/AdminModel.hpp b/loolwsd/AdminModel.hpp
index b24776e..f2163b5 100644
--- a/loolwsd/AdminModel.hpp
+++ b/loolwsd/AdminModel.hpp
@@ -43,18 +43,14 @@ private:
 class Document
 {
 public:
-    Document(std::string docKey, Poco::Process::PID pid, std::string filename)
-        : _docKey(std::move(docKey)),
+    Document(const std::string& docKey,
+             Poco::Process::PID pid,
+             const std::string& filename)
+        : _docKey(docKey),
           _pid(pid),
-          _filename(std::move(filename)),
+          _filename(filename),
           _start(std::time(nullptr))
     {
-        Log::info("Document " + _docKey + " ctor.");
-    }
-
-    ~Document()
-    {
-        Log::info("Document " + _docKey + " dtor.");
     }
 
     Poco::Process::PID getPid() const { return _pid; }


More information about the Libreoffice-commits mailing list