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 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 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::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) {}