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 16a338e173
,
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.lunak@collabora.com>
This commit is contained in:
@@ -166,10 +166,10 @@ public:
|
|||||||
typedef list_iterator_t iterator;
|
typedef list_iterator_t iterator;
|
||||||
typedef list_const_iterator_t const_iterator;
|
typedef list_const_iterator_t const_iterator;
|
||||||
|
|
||||||
// a size of 0 effectively disables the LRU cleanup code
|
|
||||||
lru_map(size_t nMaxSize)
|
lru_map(size_t nMaxSize)
|
||||||
: mMaxSize(nMaxSize ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size()))
|
: mMaxSize(nMaxSize)
|
||||||
{
|
{
|
||||||
|
assert(mMaxSize > 0);
|
||||||
}
|
}
|
||||||
~lru_map()
|
~lru_map()
|
||||||
{
|
{
|
||||||
@@ -182,7 +182,8 @@ public:
|
|||||||
|
|
||||||
void setMaxSize(size_t nMaxSize)
|
void setMaxSize(size_t nMaxSize)
|
||||||
{
|
{
|
||||||
mMaxSize = nMaxSize ? nMaxSize : std::min(mLruMap.max_size(), mLruList.max_size());
|
mMaxSize = nMaxSize;
|
||||||
|
assert(mMaxSize > 0);
|
||||||
checkLRUMaxSize();
|
checkLRUMaxSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@ public:
|
|||||||
void testLruRemoval();
|
void testLruRemoval();
|
||||||
void testCustomHash();
|
void testCustomHash();
|
||||||
void testRemoveIf();
|
void testRemoveIf();
|
||||||
void testNoAutoCleanup();
|
|
||||||
void testChangeMaxSize();
|
void testChangeMaxSize();
|
||||||
void testCustomItemSize();
|
void testCustomItemSize();
|
||||||
|
|
||||||
@@ -38,7 +37,6 @@ public:
|
|||||||
CPPUNIT_TEST(testLruRemoval);
|
CPPUNIT_TEST(testLruRemoval);
|
||||||
CPPUNIT_TEST(testCustomHash);
|
CPPUNIT_TEST(testCustomHash);
|
||||||
CPPUNIT_TEST(testRemoveIf);
|
CPPUNIT_TEST(testRemoveIf);
|
||||||
CPPUNIT_TEST(testNoAutoCleanup);
|
|
||||||
CPPUNIT_TEST(testChangeMaxSize);
|
CPPUNIT_TEST(testChangeMaxSize);
|
||||||
CPPUNIT_TEST(testCustomItemSize);
|
CPPUNIT_TEST(testCustomItemSize);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
@@ -295,24 +293,6 @@ void lru_map_test::testRemoveIf()
|
|||||||
CPPUNIT_ASSERT_EQUAL(size_t(0), lru.size());
|
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()
|
void lru_map_test::testChangeMaxSize()
|
||||||
{
|
{
|
||||||
o3tl::lru_map<int, int> lru(3);
|
o3tl::lru_map<int, int> lru(3);
|
||||||
|
@@ -88,7 +88,7 @@ bool ImplFontCache::IFSD_Equal::operator()(const vcl::font::FontSelectPattern& r
|
|||||||
|
|
||||||
ImplFontCache::ImplFontCache()
|
ImplFontCache::ImplFontCache()
|
||||||
: mpLastHitCacheEntry( nullptr )
|
: 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.
|
// The cache limit is set by the rough number of characters needed to read your average Asian newspaper.
|
||||||
, m_aBoundRectCache(3000)
|
, m_aBoundRectCache(3000)
|
||||||
{}
|
{}
|
||||||
|
Reference in New Issue
Block a user