include/o3tl/lru_map.hxx | 7 ++++--- o3tl/qa/test-lru_map.cxx | 20 -------------------- vcl/source/font/fontcache.cxx | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-)
New commits: commit 0cc8da4c091ac5784c0b4c2c7850ca8dabffea04 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon May 2 10:52:50 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Tue May 3 06:54:54 2022 +0200 remove the o3tl::lru_map "unlimited" hack It didn't quite make sense before that maxsize == 0 meant no cleanup, and now with items optionally being count as having size more than 1 it makes even less sense to limit the size to max_size() of the containers. This comes from 16a338e173083954a9932a3a4005f17230, so instead make that special caller pass a large size, which in practice is the same. Change-Id: Id875862126200ba889211f6e4079ae5921f27650 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133690 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/include/o3tl/lru_map.hxx b/include/o3tl/lru_map.hxx index 42cb932786b0..859617e5d988 100644 --- a/include/o3tl/lru_map.hxx +++ b/include/o3tl/lru_map.hxx @@ -166,10 +166,10 @@ 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 ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size())) + : mMaxSize(nMaxSize) { + assert(mMaxSize > 0); } ~lru_map() { @@ -182,7 +182,8 @@ public: void setMaxSize(size_t nMaxSize) { - mMaxSize = nMaxSize ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size()); + mMaxSize = nMaxSize; + assert(mMaxSize > 0); checkLRUMaxSize(); } diff --git a/o3tl/qa/test-lru_map.cxx b/o3tl/qa/test-lru_map.cxx index edc9d7e1bf98..c99a803b3163 100644 --- a/o3tl/qa/test-lru_map.cxx +++ b/o3tl/qa/test-lru_map.cxx @@ -27,7 +27,6 @@ public: void testLruRemoval(); void testCustomHash(); void testRemoveIf(); - void testNoAutoCleanup(); void testChangeMaxSize(); void testCustomItemSize(); @@ -38,7 +37,6 @@ public: CPPUNIT_TEST(testLruRemoval); CPPUNIT_TEST(testCustomHash); CPPUNIT_TEST(testRemoveIf); - CPPUNIT_TEST(testNoAutoCleanup); CPPUNIT_TEST(testChangeMaxSize); CPPUNIT_TEST(testCustomItemSize); CPPUNIT_TEST_SUITE_END(); @@ -295,24 +293,6 @@ void lru_map_test::testRemoveIf() CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); } -void lru_map_test::testNoAutoCleanup() -{ - o3tl::lru_map<int, int> lru(0); - CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size()); - lru.insert({ 0, 0 }); - lru.insert({ 1, 1 }); - CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size()); - lru.insert({ 0, 0 }); - CPPUNIT_ASSERT_EQUAL(size_t(2), lru.size()); - - int i = 0; - for (auto& rPair : lru) - { - CPPUNIT_ASSERT_EQUAL(i, rPair.first); - ++i; - } -} - void lru_map_test::testChangeMaxSize() { o3tl::lru_map<int, int> lru(3); diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx index b98d1bb644cc..9a87d02bcda2 100644 --- a/vcl/source/font/fontcache.cxx +++ b/vcl/source/font/fontcache.cxx @@ -88,7 +88,7 @@ bool ImplFontCache::IFSD_Equal::operator()(const vcl::font::FontSelectPattern& r ImplFontCache::ImplFontCache() : mpLastHitCacheEntry( nullptr ) - , maFontInstanceList(0) + , maFontInstanceList(std::numeric_limits<size_t>::max()) // "unlimited", i.e. no cleanup // The cache limit is set by the rough number of characters needed to read your average Asian newspaper. , m_aBoundRectCache(3000) {}