diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-15 17:18:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-17 08:22:29 +0200 |
commit | 790a32e2d22e48d5eb3463febf04874d8ae11782 (patch) | |
tree | 4c361d54d84c1208c513d7aef3d9332ec63eb396 /vcl/unx | |
parent | f58933829dc6c11a06255ae8d5417dea56264c49 (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/unx')
-rw-r--r-- | vcl/unx/generic/gdi/salbmp.cxx | 49 |
1 files changed, 12 insertions, 37 deletions
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(); } |