[Libreoffice-commits] core.git: include/tools tools/source

Takeshi Abe tabe at fixedpoint.jp
Tue Oct 14 09:31:37 PDT 2014


 include/tools/unqidx.hxx         |    7 +++++--
 tools/source/memtools/unqidx.cxx |   36 ++++++++++++++++++------------------
 2 files changed, 23 insertions(+), 20 deletions(-)

New commits:
commit 4e3772b1b472636b381ed511dcfff216fbe55d37
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Oct 13 21:05:31 2014 +0900

    fdo#75757: remove inheritance to std::map
    
    from UniqueIndexImpl.
    
    Change-Id: Iaa9040dff117ed5b05955c9f6eef31878dccf3b0
    Reviewed-on: https://gerrit.libreoffice.org/11951
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index 9042476..27de75f 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -25,18 +25,21 @@
 
 #define UNIQUEINDEX_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
 
-class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl : public std::map<sal_uInt32, void*>
+class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl
 {
 private:
+    std::map<sal_uInt32, void*> maMap;
     sal_uIntPtr   nStartIndex;
     sal_uIntPtr   nUniqIndex;
     sal_uIntPtr   nCount;
 
 public:
     UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 )
-        : std::map<sal_uInt32, void*>(),
+        : maMap(),
           nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
 
+    size_t size() const { return maMap.size(); }
+
     sal_uIntPtr   Insert( void* p );
     // insert value with key, replacing existing entry if necessary
     void          Insert( sal_uIntPtr aIndex, void* p );
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index d9d7e7b..726c96c 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -26,7 +26,7 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p )
         return UNIQUEINDEX_ENTRY_NOTFOUND;
 
    // Expend array if full
-    sal_uIntPtr nTmp = size();
+    sal_uIntPtr nTmp = maMap.size();
     if( nTmp == nCount )
         nTmp++;
 
@@ -34,11 +34,11 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p )
     nUniqIndex = nUniqIndex % nTmp;
 
     // Search next empty index
-    while ( find( nUniqIndex ) != end() )
+    while ( maMap.find( nUniqIndex ) != maMap.end() )
         nUniqIndex = (nUniqIndex+1) % nTmp;
 
     // Insert object to array
-    (*this)[ nUniqIndex ] = p;
+    maMap[ nUniqIndex ] = p;
 
     nCount++;
     nUniqIndex++;
@@ -53,10 +53,10 @@ void UniqueIndexImpl::Insert( sal_uIntPtr nIndex, void* p )
 
     sal_uIntPtr nContIndex = nIndex - nStartIndex;
 
-    bool bFound = find( nContIndex ) != end();
+    bool bFound = maMap.find( nContIndex ) != maMap.end();
 
     // Insert object to array
-    (*this)[ nContIndex ] = p;
+    maMap[ nContIndex ] = p;
 
     if( !bFound )
         nCount++;
@@ -70,11 +70,11 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
     {
         // insert index as empty entry, and reduce indexcount,
         // if this entry was used
-        iterator it = find( nIndex - nStartIndex );
-        if( it != end() )
+        std::map<sal_uInt32, void*>::iterator it = maMap.find( nIndex - nStartIndex );
+        if( it != maMap.end() )
         {
             void* p = it->second;
-            erase( it );
+            maMap.erase( it );
             nCount--;
             return p;
         }
@@ -88,8 +88,8 @@ void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
     if ( (nIndex >= nStartIndex) &&
          (nIndex < (size() + nStartIndex)) )
     {
-        const_iterator it = find( nIndex - nStartIndex );
-        if( it != end() )
+        std::map<sal_uInt32, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
+        if( it != maMap.end() )
             return it->second;
     }
     return NULL;
@@ -97,34 +97,34 @@ void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
 
 sal_uIntPtr UniqueIndexImpl::FirstIndex() const
 {
-    if ( empty() )
+    if ( maMap.empty() )
         return UNIQUEINDEX_ENTRY_NOTFOUND;
 
-    return begin()->first;
+    return maMap.begin()->first;
 }
 
 sal_uIntPtr UniqueIndexImpl::LastIndex() const
 {
-    if ( empty() )
+    if ( maMap.empty() )
         return UNIQUEINDEX_ENTRY_NOTFOUND;
 
-    return rbegin()->first;
+    return maMap.rbegin()->first;
 }
 
 sal_uIntPtr UniqueIndexImpl::NextIndex(sal_uIntPtr aIndex) const
 {
-    const_iterator it = find( aIndex );
-    if ( it == end() )
+    std::map<sal_uInt32, void*>::const_iterator it = maMap.find( aIndex );
+    if ( it == maMap.end() )
         return UNIQUEINDEX_ENTRY_NOTFOUND;
     ++it;
-    if ( it == end() )
+    if ( it == maMap.end() )
         return UNIQUEINDEX_ENTRY_NOTFOUND;
     return it->first;
 }
 
 sal_uIntPtr UniqueIndexImpl::GetIndexOf(void* p) const
 {
-    for( const_iterator it = begin(); it != end(); ++it )
+    for( std::map<sal_uInt32, void*>::const_iterator it = maMap.begin(); it != maMap.end(); ++it )
         if( it->second == p )
             return it->first;
     return UNIQUEINDEX_ENTRY_NOTFOUND;


More information about the Libreoffice-commits mailing list