From 16a338e173083954a9932a3a4005f172309c784e Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Fri, 5 Oct 2018 17:08:49 +0200 Subject: 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 --- include/o3tl/lru_map.hxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/o3tl') 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> +template, class KeyEqual = std::equal_to> 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 map_t; + typedef std::unordered_map 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) -- cgit