summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-10-05 17:08:49 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2018-10-06 16:23:44 +0200
commit16a338e173083954a9932a3a4005f172309c784e (patch)
treec401b0f8857e61147d5a0b2d7dc239fed9e047d5 /include/o3tl
parent01a782d2ceb741d20721b44d26d862d80b47d226 (diff)
Convert ImplFontCache to use o3tl::lru_map
We still do our own cleanup of the LRU map, as we can't drop any fonts in use. Change-Id: I8ec5c6ce8f80893635621357e9085950e7010f5b Reviewed-on: https://gerrit.libreoffice.org/61455 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/lru_map.hxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx
index 79e81293a858..003da59551b5 100644
--- a/include/o3tl/lru_map.hxx
+++ b/include/o3tl/lru_map.hxx
@@ -31,7 +31,7 @@ namespace o3tl
* for most of the operations with a combination unordered map and linked list.
*
**/
-template<typename Key, typename Value, class KeyHash = std::hash<Key>>
+template<typename Key, typename Value, class KeyHash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
class lru_map final
{
public:
@@ -42,7 +42,7 @@ private:
typedef typename list_t::iterator list_iterator_t;
typedef typename list_t::const_iterator list_const_iterator_t;
- typedef std::unordered_map<Key, list_iterator_t, KeyHash> map_t;
+ typedef std::unordered_map<Key, list_iterator_t, KeyHash, KeyEqual> map_t;
typedef typename map_t::iterator map_iterator_t;
typedef typename map_t::const_iterator map_const_iterator_t;
@@ -65,8 +65,9 @@ public:
typedef list_iterator_t iterator;
typedef list_const_iterator_t const_iterator;
+ // a size of 0 effectively disables the LRU cleanup code
lru_map(size_t nMaxSize)
- : mMaxSize(nMaxSize)
+ : mMaxSize(nMaxSize ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size()))
{}
void insert(key_value_pair_t& rPair)