[Libreoffice-commits] core.git: vcl/inc vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 17 06:22:55 UTC 2018


 vcl/inc/unx/salbmp.h           |    6 +----
 vcl/unx/generic/gdi/salbmp.cxx |   49 ++++++++++-------------------------------
 2 files changed, 14 insertions(+), 41 deletions(-)

New commits:
commit 790a32e2d22e48d5eb3463febf04874d8ae11782
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 15 17:18:25 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 17 08:22:29 2018 +0200

    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 at collabora.co.uk>

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();
 }


More information about the Libreoffice-commits mailing list