[Libreoffice-commits] online.git: wsd/SenderQueue.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Dec 19 05:59:40 UTC 2016


 wsd/SenderQueue.hpp |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 49af971efbc3dc0c3af8b48f94fba26a037beaaf
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Dec 18 14:11:36 2016 -0500

    wsd: simplify tile deduplication
    
    Change-Id: I34d83acc81b8169d8ae07ed53219b11fe0f0fec2
    Reviewed-on: https://gerrit.libreoffice.org/32161
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/SenderQueue.hpp b/wsd/SenderQueue.hpp
index 2864dae..4e1c425 100644
--- a/wsd/SenderQueue.hpp
+++ b/wsd/SenderQueue.hpp
@@ -175,23 +175,23 @@ private:
     /// enqueued, otherwise false.
     bool deduplicate(const Item& item)
     {
+        // Deduplicate messages based on the incoming one.
         const std::string command = item->firstToken();
         if (command == "tile:")
         {
-            TileDesc newTile = TileDesc::parse(item->firstLine());
-            auto begin = std::remove_if(_queue.begin(), _queue.end(),
-            [&newTile](const queue_item_t& cur)
-            {
-                const std::string curCommand = cur->firstToken();
-                if (curCommand == "tile:")
+            // Remove previous identical tile, if any, and use most recent (incoming).
+            const TileDesc newTile = TileDesc::parse(item->firstLine());
+            const auto& pos = std::find_if(_queue.begin(), _queue.end(),
+                [&newTile](const queue_item_t& cur)
                 {
-                    return (newTile == TileDesc::parse(cur->firstLine()));
-                }
-
-                return false;
-            });
+                    return (cur->firstToken() == "tile:" &&
+                            newTile == TileDesc::parse(cur->firstLine()));
+                });
 
-            _queue.erase(begin, _queue.end());
+            if (pos != _queue.end())
+            {
+                _queue.erase(pos);
+            }
         }
 
         return true;


More information about the Libreoffice-commits mailing list