summaryrefslogtreecommitdiff
path: root/vcl/source/font/fontcache.cxx
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-01-28 22:46:46 +0100
committerJulien Nabet <serval2412@yahoo.fr>2018-01-29 07:02:23 +0100
commit85b3c799ede62a3d7ad0493fc80b629214956601 (patch)
tree28744ea275da6fce4bab05aaeed97d0ca21108e7 /vcl/source/font/fontcache.cxx
parentfe41d0ff8c426fe5934872de8b0dcb167cb636a2 (diff)
Modernize a bit vcl (part2)
by using for-range loops + use returned iterator by erase method + avoid some iterators calculus by using plain loop Change-Id: I196a52c3c7d0e2705d5ab0e3ea06bd4a4b83bb67 Reviewed-on: https://gerrit.libreoffice.org/48805 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'vcl/source/font/fontcache.cxx')
-rw-r--r--vcl/source/font/fontcache.cxx23
1 files changed, 11 insertions, 12 deletions
diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx
index 874fd1e0cddc..011212fbdde3 100644
--- a/vcl/source/font/fontcache.cxx
+++ b/vcl/source/font/fontcache.cxx
@@ -91,10 +91,9 @@ ImplFontCache::ImplFontCache()
ImplFontCache::~ImplFontCache()
{
- FontInstanceList::iterator it = maFontInstanceList.begin();
- for(; it != maFontInstanceList.end(); ++it )
+ for (auto const& fontInstance : maFontInstanceList)
{
- LogicalFontInstance* pFontInstance = (*it).second;
+ LogicalFontInstance* pFontInstance = fontInstance.second;
delete pFontInstance;
}
}
@@ -268,12 +267,14 @@ void ImplFontCache::Release(LogicalFontInstance* pFontInstance)
FontInstanceList::iterator it_next = maFontInstanceList.begin();
while( it_next != maFontInstanceList.end() )
{
- FontInstanceList::iterator it = it_next++;
- LogicalFontInstance* pFontEntry = (*it).second;
+ LogicalFontInstance* pFontEntry = (*it_next).second;
if( pFontEntry->mnRefCount > 0 )
+ {
+ ++it_next;
continue;
+ }
- maFontInstanceList.erase( it );
+ it_next = maFontInstanceList.erase(it_next);
delete pFontEntry;
--mnRef0Count;
assert(mnRef0Count>=0 && "ImplFontCache::Release() - refcount0 underflow");
@@ -295,10 +296,9 @@ int ImplFontCache::CountUnreferencedEntries() const
{
size_t nCount = 0;
// count unreferenced entries
- for (FontInstanceList::const_iterator it = maFontInstanceList.begin();
- it != maFontInstanceList.end(); ++it)
+ for (auto const& fontInstance : maFontInstanceList)
{
- const LogicalFontInstance* pFontEntry = it->second;
+ const LogicalFontInstance* pFontEntry = fontInstance.second;
if (pFontEntry->mnRefCount > 0)
continue;
++nCount;
@@ -311,10 +311,9 @@ void ImplFontCache::Invalidate()
assert(CountUnreferencedEntries() == mnRef0Count);
// delete unreferenced entries
- FontInstanceList::iterator it = maFontInstanceList.begin();
- for(; it != maFontInstanceList.end(); ++it )
+ for (auto const& fontInstance : maFontInstanceList)
{
- LogicalFontInstance* pFontEntry = (*it).second;
+ LogicalFontInstance* pFontEntry = fontInstance.second;
if( pFontEntry->mnRefCount > 0 )
{
// These fonts will become orphans after clearing the list below;