wsd/TileCache.cpp |    2 +-
 wsd/TileDesc.hpp  |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 999df3fffb9c100a86acd200fdc9066203a13553
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Sun Aug 9 17:55:56 2020 -0400
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Mon Aug 10 16:00:27 2020 +0200

    wsd: hashmaps have better data locality
    
    They are especially efficient for small lookups.
    
    Change-Id: Ia005f40127cf222debe185515fc45cd92b8ae752
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100413
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 982cd985b..d36ca1aa6 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -552,7 +552,7 @@ void TileCache::saveDataToCache(const TileDesc &desc, const 
char *data, const si
 
     TileCache::Tile tile = std::make_shared<std::vector<char>>(size);
     std::memcpy(tile->data(), data, size);
-    auto res = _cache.insert(std::make_pair(desc, tile));
+    auto res = _cache.emplace(desc, tile);
     if (!res.second)
     {
         _cacheSize -= itemCacheSize(res.first->second);
diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp
index 28ecc4256..e60984359 100644
--- a/wsd/TileDesc.hpp
+++ b/wsd/TileDesc.hpp
@@ -10,7 +10,7 @@
 #pragma once
 
 #include <cassert>
-#include <map>
+#include <unordered_map>
 #include <sstream>
 #include <string>
 
@@ -24,7 +24,7 @@ using TileBinaryHash = uint64_t;
 
 /// Tile Descriptor
 /// Represents a tile's coordinates and dimensions.
-class TileDesc
+class TileDesc final
 {
 public:
     TileDesc(int normalizedViewId, int part, int width, int height, int 
tilePosX, int tilePosY, int tileWidth,
@@ -206,7 +206,7 @@ public:
     {
         // We don't expect undocumented fields and
         // assume all values to be int.
-        std::map<std::string, int> pairs;
+        std::unordered_map<std::string, int> pairs(16);
 
         // Optional.
         pairs["ver"] = -1;
@@ -261,7 +261,7 @@ public:
         return tileID.str();
     }
 
-protected:
+private:
     int _normalizedViewId;
     int _part;
     int _width;
@@ -281,7 +281,7 @@ protected:
 /// One or more tile header.
 /// Used to request the rendering of multiple
 /// tiles as well as the header of the response.
-class TileCombined
+class TileCombined final
 {
 private:
     TileCombined(int normalizedViewId, int part, int width, int height,
@@ -465,7 +465,7 @@ public:
     {
         // We don't expect undocumented fields and
         // assume all values to be int.
-        std::map<std::string, int> pairs;
+        std::unordered_map<std::string, int> pairs(16);
 
         std::string tilePositionsX;
         std::string tilePositionsY;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to