summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-15 17:18:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-17 08:22:29 +0200
commit790a32e2d22e48d5eb3463febf04874d8ae11782 (patch)
tree4c361d54d84c1208c513d7aef3d9332ec63eb396 /vcl
parentf58933829dc6c11a06255ae8d5417dea56264c49 (diff)
loplugin:useuniqueptr in ImplSalBitmapCache
and dramatically simplify Change-Id: If0947125cd599ca5e2d5a9dc5974a646d4bca605 Reviewed-on: https://gerrit.libreoffice.org/59222 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/salbmp.h6
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx49
2 files changed, 14 insertions, 41 deletions
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 34c7ff076156..82ed6c3bd724 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -211,14 +211,12 @@ public:
};
-struct ImplBmpObj;
+class X11SalBitmap;
class ImplSalBitmapCache
{
private:
- typedef ::std::list< ImplBmpObj* > BmpList_impl;
-
- BmpList_impl maBmpList;
+ std::vector<X11SalBitmap*> maBmpList;
public:
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index f800a776a6e3..5dcfcef19974 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -1058,14 +1058,6 @@ void ImplSalDDB::ImplDraw(
}
-struct ImplBmpObj
-{
- X11SalBitmap* mpBmp;
-
- ImplBmpObj( X11SalBitmap* pBmp ) :
- mpBmp( pBmp ) {}
-};
-
ImplSalBitmapCache::ImplSalBitmapCache()
{
}
@@ -1077,34 +1069,21 @@ ImplSalBitmapCache::~ImplSalBitmapCache()
void ImplSalBitmapCache::ImplAdd( X11SalBitmap* pBmp )
{
- ImplBmpObj* pObj = nullptr;
- bool bFound = false;
-
- for(
- BmpList_impl::iterator it = maBmpList.begin();
- (it != maBmpList.end() ) && !bFound ;
- ++it
- ) {
- pObj = *it;
- if( pObj->mpBmp == pBmp )
- bFound = true;
+ for(auto pObj : maBmpList)
+ {
+ if( pObj == pBmp )
+ return;
}
-
- if( !bFound )
- maBmpList.push_back( new ImplBmpObj( pBmp ) );
+ maBmpList.push_back( pBmp );
}
void ImplSalBitmapCache::ImplRemove( X11SalBitmap const * pBmp )
{
- for(
- BmpList_impl::iterator it = maBmpList.begin();
- it != maBmpList.end();
- ++it
- ) {
- if( (*it)->mpBmp == pBmp )
+ for( auto it = maBmpList.begin(); it != maBmpList.end(); ++it)
+ {
+ if( *it == pBmp )
{
- (*it)->mpBmp->ImplRemovedFromCache();
- delete *it;
+ (*it)->ImplRemovedFromCache();
maBmpList.erase( it );
break;
}
@@ -1113,13 +1092,9 @@ void ImplSalBitmapCache::ImplRemove( X11SalBitmap const * pBmp )
void ImplSalBitmapCache::ImplClear()
{
- for(
- BmpList_impl::iterator it = maBmpList.begin();
- it != maBmpList.end();
- ++it
- ) {
- (*it)->mpBmp->ImplRemovedFromCache();
- delete *it;
+ for(auto pObj : maBmpList)
+ {
+ pObj->ImplRemovedFromCache();
}
maBmpList.clear();
}