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

Matteo Casalin matteo.casalin at yahoo.com
Tue Mar 1 22:51:24 UTC 2016


 include/tools/pstm.hxx           |   16 +++++++-----
 include/tools/unqidx.hxx         |   49 +++++++++++++++++++++------------------
 rsc/inc/rscdb.hxx                |    6 ++--
 rsc/inc/rscdef.hxx               |   27 +++++++++++----------
 rsc/source/parser/rscdb.cxx      |   24 +++++++++----------
 rsc/source/parser/rsclex.cxx     |    2 -
 rsc/source/parser/rscyacc.y      |    1 
 rsc/source/rsc/rsc.cxx           |   26 ++++++++++----------
 rsc/source/tools/rscdef.cxx      |   49 ++++++++++++++++++---------------------
 tools/source/memtools/unqidx.cxx |   36 ++++++++++++++--------------
 tools/source/ref/pstm.cxx        |   14 +++++------
 11 files changed, 130 insertions(+), 120 deletions(-)

New commits:
commit 0d34f4ac9b17348d7956285c6cefb28bea2537b6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Tue Mar 1 23:37:07 2016 +0100

    Data member nStartIndex can be const
    
    Change-Id: I94a3bdd01186061fbd95b62494c24a50f0c4866d

diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index c783151..dd66c300 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -33,7 +33,7 @@ public:
 
 private:
     std::map<Index, void*> maMap;
-    Index nStartIndex;
+    const Index nStartIndex;
     Index nUniqIndex;
     Index nCount;
 
commit f00967cf38ed0c2c197284391fc521825bb3c2ac
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Tue Mar 1 23:21:02 2016 +0100

    sal_uIntPtr/sal_uLong to Index (aka sal_uInt32) in UniqueIndex
    
    Change-Id: I212cb3bb9d920741629fc4564bbd28b393e8fe00

diff --git a/include/tools/pstm.hxx b/include/tools/pstm.hxx
index 92b5349..ab75416 100644
--- a/include/tools/pstm.hxx
+++ b/include/tools/pstm.hxx
@@ -91,8 +91,6 @@ public:
                                           SvPersistBase *& rpObj );
 };
 
-typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap;
-
 class SvStream;
 
 /** Persistent Stream
@@ -130,12 +128,18 @@ class SvStream;
 */
 class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
 {
+public:
+    typedef UniqueIndex<SvPersistBase>::Index Index;
+
+private:
+    typedef std::map<SvPersistBase*, Index> PersistBaseMap;
+
     SvClassManager &    rClassMgr;
     SvStream *          pStm;
     PersistBaseMap      aPTable; // reversed pointer and key
     UniqueIndex<SvPersistBase>
                         aPUIdx;
-    sal_uIntPtr         nStartIdx;
+    Index               nStartIdx;
     const SvPersistStream * pRefStm;
 
     virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize ) override;
@@ -151,13 +155,13 @@ public:
     virtual void        ResetError() override;
 
                         SvPersistStream( SvClassManager &, SvStream * pStream,
-                                         sal_uInt32 nStartIdx = 1 );
+                                         Index nStartIdx = 1 );
                         virtual ~SvPersistStream();
 
     void                SetStream( SvStream * pStream );
 
-    SvPersistBase *     GetObject( sal_uIntPtr nIdx ) const;
-    sal_uIntPtr         GetIndex( SvPersistBase * ) const;
+    SvPersistBase *     GetObject( Index nIdx ) const;
+    Index               GetIndex( SvPersistBase * ) const;
 
     static void         WriteCompressed( SvStream & rStm, sal_uInt32 nVal );
     static sal_uInt32   ReadCompressed( SvStream & rStm );
diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index 03a30c6..c783151 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -20,45 +20,52 @@
 #define INCLUDED_TOOLS_UNQIDX_HXX
 
 #include <tools/toolsdllapi.h>
-#include <tools/contnr.hxx>
+#include <limits>
 #include <map>
 
-#define UNIQUEINDEX_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
-
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC UniqueIndexImpl
 {
+public:
+    typedef sal_uInt32 Index;
+    enum {
+        IndexNotFound = std::numeric_limits<Index>::max()
+    };
+
 private:
-    std::map<sal_uInt32, void*> maMap;
-    sal_uIntPtr   nStartIndex;
-    sal_uIntPtr   nUniqIndex;
-    sal_uIntPtr   nCount;
+    std::map<Index, void*> maMap;
+    Index nStartIndex;
+    Index nUniqIndex;
+    Index nCount;
 
 public:
-    UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 )
+    UniqueIndexImpl( Index _nStartIndex = 0 )
         : maMap(),
           nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
 
-    sal_uIntPtr   Insert( void* p );
+    Index Insert( void* p );
     // insert value with key, replacing existing entry if necessary
-    void*         Remove( sal_uIntPtr aIndex );
-    void*         Get( sal_uIntPtr aIndex ) const;
+    void* Remove( Index aIndex );
+    void* Get( Index aIndex ) const;
 
-    sal_uIntPtr   GetIndexOf( void* p ) const;
-    sal_uIntPtr   FirstIndex() const;
-    sal_uIntPtr   LastIndex() const;
-    sal_uIntPtr   NextIndex( sal_uIntPtr aCurrIndex ) const;
+    Index GetIndexOf( void* p ) const;
+    Index FirstIndex() const;
+    Index LastIndex() const;
+    Index NextIndex( Index aCurrIndex ) const;
 };
 
 template<typename T>
 class UniqueIndex : private UniqueIndexImpl
 {
 public:
-    UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {}
+    using UniqueIndexImpl::Index;
+    using UniqueIndexImpl::IndexNotFound;
+
+    UniqueIndex<T>( Index _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {}
 
-    sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); }
-    T*          Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); }
-    T*          Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); }
-    sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); }
+    Index Insert(T* p) { return UniqueIndexImpl::Insert(p); }
+    T*    Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); }
+    T*    Remove(Index idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); }
+    Index GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); }
 
     using UniqueIndexImpl::FirstIndex;
     using UniqueIndexImpl::LastIndex;
diff --git a/rsc/inc/rscdb.hxx b/rsc/inc/rscdb.hxx
index c7c4958..9aadf3d 100644
--- a/rsc/inc/rscdb.hxx
+++ b/rsc/inc/rscdb.hxx
@@ -223,7 +223,7 @@ class RscTypCont
 
     void        InsWinBit( RscTop * pClass, const OString& rName,
                            Atom nVal );
-    void        WriteInc( FILE * fOutput, sal_uLong lKey );
+    void        WriteInc( FILE * fOutput, RscFileTab::Index lKey );
 
 public:
     RscBool             aBool;
@@ -274,13 +274,13 @@ public:
                           }
     RscTop  *         SearchType( Atom nTypId );
                       // deletes all resource objects of this file
-    void              Delete( sal_uLong lFileKey );
+    void              Delete( RscFileTab::Index lFileKey );
     RscTop  *         GetRoot()         { return pRoot; }
     sal_uInt32        PutSysName( sal_uInt32 nRscTyp, char * pName, sal_uInt32 nConst,
                                   sal_uInt32 nId, bool bFirst );
     void              ClearSysNames();
     ERRTYPE           WriteRc( WriteRcContext& rContext );
-    void              WriteSrc( FILE * fOutput, sal_uLong nFileIndex,
+    void              WriteSrc( FILE * fOutput, RscFileTab::Index nFileIndex,
                                 bool bName = true );
     void              PutTranslatorKey( sal_uInt64 nKey );
     void              IncFilePos( sal_uLong nOffset ){ nFilePos += nOffset; }
diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx
index 41e22f6..d2194f0 100644
--- a/rsc/inc/rscdef.hxx
+++ b/rsc/inc/rscdef.hxx
@@ -221,8 +221,6 @@ public:
     bool            IsIncFile(){  return bIncFile; };
 };
 
-#define NOFILE_INDEX UNIQUEINDEX_ENTRY_NOTFOUND
-
 class RscDefTree
 {
     RscDefine * pDefRoot;
@@ -238,8 +236,13 @@ public:
 
 class RscFileTab : public UniqueIndex<RscFile>
 {
+public:
+    using UniqueIndex<RscFile>::Index;
+    using UniqueIndex<RscFile>::IndexNotFound;
+
+private:
     RscDefTree aDefTree;
-    sal_uLong       Find(const OString& rName);
+    Index       Find(const OString& rName);
 public:
                 RscFileTab();
                 ~RscFileTab();
@@ -250,22 +253,22 @@ public:
                     return FindDef(rStr.getStr());
                 }
 
-    bool        Depend( sal_uLong lDepend, sal_uLong lFree );
-    bool        TestDef( sal_uLong lFileKey, size_t lPos,
+    bool        Depend( Index lDepend, Index lFree );
+    bool        TestDef( Index lFileKey, size_t lPos,
                          const RscDefine * pDefDec );
-    bool        TestDef( sal_uLong lFileKey, size_t lPos,
+    bool        TestDef( Index lFileKey, size_t lPos,
                          const RscExpression * pExpDec );
 
-    RscDefine * NewDef( sal_uLong lKey, const OString& rDefName,
+    RscDefine * NewDef( Index lKey, const OString& rDefName,
                         sal_Int32 lId, sal_uLong lPos );
-    RscDefine * NewDef( sal_uLong lKey, const OString& rDefName,
+    RscDefine * NewDef( Index lKey, const OString& rDefName,
                         RscExpression *, sal_uLong lPos );
 
            // deletes all defines defined in this file
-    void        DeleteFileContext( sal_uLong lKey );
-    sal_uLong   NewCodeFile(const OString& rName);
-    sal_uLong   NewIncFile(const OString& rName, const OString& rPath);
-    RscFile *   GetFile( sal_uLong lFileKey ){ return Get( lFileKey ); }
+    void        DeleteFileContext( Index lKey );
+    Index       NewCodeFile(const OString& rName);
+    Index       NewIncFile(const OString& rName, const OString& rPath);
+    RscFile *   GetFile( Index lFileKey ){ return Get( lFileKey ); }
 };
 
 #endif // INCLUDED_RSC_INC_RSCDEF_HXX
diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx
index c3c34e7..2c253e8 100644
--- a/rsc/source/parser/rscdb.cxx
+++ b/rsc/source/parser/rscdb.cxx
@@ -297,13 +297,13 @@ sal_uInt32 RscTypCont::PutSysName( sal_uInt32 nRscTyp, char * pFileName,
     return pSysEntry->nKey;
 }
 
-void RscTypCont::WriteInc( FILE * fOutput, sal_uLong lFileKey )
+void RscTypCont::WriteInc( FILE * fOutput, RscFileTab::Index lFileKey )
 {
 
-    if( NOFILE_INDEX == lFileKey )
+    if( lFileKey == RscFileTab::IndexNotFound )
     {
-        sal_uIntPtr aIndex = aFileTab.FirstIndex();
-        while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+        RscFileTab::Index aIndex = aFileTab.FirstIndex();
+        while( aIndex != RscFileTab::IndexNotFound )
         {
             RscFile   * pFName = aFileTab.Get( aIndex );
             if( pFName->IsIncFile() )
@@ -503,7 +503,7 @@ ERRTYPE RscTypCont::WriteRc( WriteRcContext& rContext )
     return aError;
 }
 
-void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey,
+void RscTypCont::WriteSrc( FILE * fOutput, RscFileTab::Index nFileKey,
                              bool bName )
 {
     RscEnumerateRef aEnumRef( this, pRoot, fOutput );
@@ -517,10 +517,10 @@ void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey,
         RscFile* pFName;
         WriteInc( fOutput, nFileKey );
 
-        if( NOFILE_INDEX == nFileKey )
+        if( nFileKey == RscFileTab::IndexNotFound )
         {
-            sal_uIntPtr aIndex = aFileTab.FirstIndex();
-            while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+            RscFileTab::Index aIndex = aFileTab.FirstIndex();
+            while( aIndex != RscFileTab::IndexNotFound )
             {
                 pFName = aFileTab.Get( aIndex );
                 if( !pFName->IsIncFile() )
@@ -542,10 +542,10 @@ void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey,
     else
     {
         RscId::SetNames( false );
-        if( NOFILE_INDEX == nFileKey )
+        if( nFileKey == RscFileTab::IndexNotFound )
         {
-            sal_uIntPtr aIndex = aFileTab.FirstIndex();
-            while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+            RscFileTab::Index aIndex = aFileTab.FirstIndex();
+            while( aIndex != RscFileTab::IndexNotFound )
             {
                 aEnumRef.WriteSrc( aIndex );
                 aIndex = aFileTab.NextIndex( aIndex );
@@ -579,7 +579,7 @@ IMPL_LINK_TYPED( RscDel, Delete, const NameNode&, r, void )
         pNode->pObjBiTree = pNode->GetObjNode()->DelObjNode( pNode, lFileKey );
 }
 
-void RscTypCont::Delete( sal_uLong lFileKey )
+void RscTypCont::Delete( RscFileTab::Index lFileKey )
 {
     // delete resource instance
     RscDel aDel( pRoot, lFileKey );
diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx
index 47c3187..f5f7c0c 100644
--- a/rsc/source/parser/rsclex.cxx
+++ b/rsc/source/parser/rsclex.cxx
@@ -369,7 +369,7 @@ void IncludeParser( RscFileInst * pFileInst )
     int           nToken;   // token value
     YYSTYPE       aYYSType; // token data
     RscFile     * pFName;   // file structure
-    sal_uLong         lKey;     // file key
+    RscFileTab::Index lKey;     // file key
     RscTypCont  * pTypCon  = pFileInst->pTypCont;
 
     pFName = pTypCon->aFileTab.Get( pFileInst->GetFileIndex() );
diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y
index c084d9b..c0a9114 100644
--- a/rsc/source/parser/rscyacc.y
+++ b/rsc/source/parser/rscyacc.y
@@ -20,6 +20,7 @@
 
 #include "sal/config.h"
 
+#include <limits.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx
index 77ec2b8..6d663a2 100644
--- a/rsc/source/rsc/rsc.cxx
+++ b/rsc/source/rsc/rsc.cxx
@@ -333,8 +333,8 @@ ERRTYPE RscCompiler::Start()
 
             pTC->pEH->SetListFile( nullptr );
 
-            sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-            while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk() )
+            RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+            while( aIndex != RscFileTab::IndexNotFound && aError.IsOk() )
             {
                 pFName = pTC->aFileTab.Get( aIndex );
                 if( !pFName->bScanned && !pFName->IsIncFile() )
@@ -353,8 +353,8 @@ ERRTYPE RscCompiler::Start()
     if ( pTC->pEH->GetVerbosity() >= RscVerbosityVerbose )
     {
         pTC->pEH->StdOut( "Files: " );
-        sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-        while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+        RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+        while( aIndex != RscFileTab::IndexNotFound )
         {
             pFName = pTC->aFileTab.Get( aIndex );
             pTC->pEH->StdOut( pFName->aFileName.getStr() );
@@ -395,13 +395,13 @@ void RscCompiler::EndCompile()
             else
             {
                 // write file
-                sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-                while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+                RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+                while( aIndex != RscFileTab::IndexNotFound )
                 {
                     RscFile* pFN = pTC->aFileTab.Get( aIndex );
                     if( !pFN->IsIncFile() )
                     {
-                        pTC->WriteSrc( foutput, NOFILE_INDEX, false );
+                        pTC->WriteSrc( foutput, RscFileTab::IndexNotFound, false );
                         break; // ?T 281091MM only one source file
                     }
                 }
@@ -572,8 +572,8 @@ ERRTYPE RscCompiler::Link()
         for( it = pCL->m_aOutputFiles.begin(); it != pCL->m_aOutputFiles.end(); ++it )
         {
             // cleanup nodes
-            for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-                 aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk();
+            for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+                 aIndex != RscFileTab::IndexNotFound && aError.IsOk();
                  aIndex = pTC->aFileTab.NextIndex( aIndex ) )
             {
                 pFName = pTC->aFileTab.Get( aIndex );
@@ -673,8 +673,8 @@ ERRTYPE RscCompiler::Link()
             }
 
             // parse files for specific language
-            for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-                 aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk();
+            for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+                 aIndex != RscFileTab::IndexNotFound && aError.IsOk();
                  aIndex = pTC->aFileTab.NextIndex( aIndex ) )
             {
                 pFName = pTC->aFileTab.Get( aIndex );
@@ -725,8 +725,8 @@ ERRTYPE RscCompiler::Link()
     else
     {
         // parse files
-        for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex();
-             aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk();
+        for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex();
+             aIndex != RscFileTab::IndexNotFound && aError.IsOk();
              aIndex = pTC->aFileTab.NextIndex( aIndex ) )
         {
             pFName = pTC->aFileTab.Get( aIndex );
diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx
index 155382d..c3dbffe 100644
--- a/rsc/source/tools/rscdef.cxx
+++ b/rsc/source/tools/rscdef.cxx
@@ -21,6 +21,8 @@
 // overall program includes
 #include <rscdef.hxx>
 
+#include <limits.h>
+
 bool RscId::bNames = true;
 
 void RscId::SetNames( bool bSet )
@@ -489,24 +491,21 @@ RscFileTab::~RscFileTab()
 
     aDefTree.Remove();
 
-    sal_uIntPtr aIndex = LastIndex();
-    while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+    Index aIndex = LastIndex();
+    while( aIndex != IndexNotFound )
     {
         delete Remove( aIndex );
         aIndex = LastIndex();
     };
 }
 
-sal_uLong  RscFileTab::Find( const OString& rName )
+RscFileTab::Index RscFileTab::Find( const OString& rName )
 {
-    sal_uIntPtr aIndex = FirstIndex();
-    while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && (Get(aIndex)->aFileName != rName) )
+    Index aIndex = FirstIndex();
+    while( aIndex != IndexNotFound && (Get(aIndex)->aFileName != rName) )
         aIndex = NextIndex(aIndex);
 
-    if( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
-        return aIndex;
-    else
-        return NOFILE_INDEX;
+    return aIndex;
 }
 
 RscDefine * RscFileTab::FindDef( const char * pName )
@@ -516,13 +515,13 @@ RscDefine * RscFileTab::FindDef( const char * pName )
 
 /* This method gives back true when lDepend
    exists and is behind lFree, or when lDepend does not exist. */
-bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree )
+bool RscFileTab::Depend( Index lDepend, Index lFree )
 {
     if( lDepend == lFree )
         return true;
 
-    sal_uIntPtr aIndex = FirstIndex();
-    while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND )
+    Index aIndex = FirstIndex();
+    while( aIndex != IndexNotFound )
     {
         RscFile * pFile = Get(aIndex);
         if( !pFile->IsIncFile() )
@@ -536,7 +535,7 @@ bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree )
     return true;
 }
 
-bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
+bool RscFileTab::TestDef( Index lFileKey, size_t lPos,
                           const RscDefine * pDefDec )
 {
     if( lFileKey == pDefDec->GetFileKey() )
@@ -554,7 +553,7 @@ bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
     return TestDef( lFileKey, lPos, pDefDec->pExp );
 }
 
-bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
+bool RscFileTab::TestDef( Index lFileKey, size_t lPos,
                           const RscExpression * pExpDec )
 {
     if( !pExpDec )
@@ -579,7 +578,7 @@ bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos,
     return true;
 }
 
-RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName,
+RscDefine * RscFileTab::NewDef( Index lFileKey, const OString& rDefName,
                                 sal_Int32 lId, sal_uLong lPos )
 {
     RscDefine * pDef = FindDef( rDefName );
@@ -600,7 +599,7 @@ RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName,
     return pDef;
 }
 
-RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName,
+RscDefine * RscFileTab::NewDef( Index lFileKey, const OString& rDefName,
                                 RscExpression * pExp, sal_uLong lPos )
 {
     RscDefine * pDef = FindDef( rDefName );
@@ -630,11 +629,9 @@ RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName,
     return pDef;
 }
 
-void RscFileTab::DeleteFileContext( sal_uLong lFileKey )
+void RscFileTab::DeleteFileContext( Index lFileKey )
 {
-    RscFile     * pFName;
-
-    pFName = GetFile( lFileKey );
+    RscFile* pFName = GetFile( lFileKey );
     if( pFName )
     {
         for ( size_t i = 0, n = pFName->aDefLst.maList.size(); i < n; ++i )
@@ -647,10 +644,10 @@ void RscFileTab::DeleteFileContext( sal_uLong lFileKey )
     }
 }
 
-sal_uLong  RscFileTab::NewCodeFile( const OString& rName )
+RscFileTab::Index RscFileTab::NewCodeFile( const OString& rName )
 {
-    sal_uLong lKey = Find( rName );
-    if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey )
+    Index lKey = Find( rName );
+    if( lKey == IndexNotFound )
     {
         RscFile * pFName = new RscFile();
         pFName->aFileName = rName;
@@ -661,11 +658,11 @@ sal_uLong  RscFileTab::NewCodeFile( const OString& rName )
     return lKey;
 }
 
-sal_uLong  RscFileTab::NewIncFile(const OString& rName,
+RscFileTab::Index RscFileTab::NewIncFile(const OString& rName,
                                     const OString& rPath)
 {
-    sal_uLong lKey = Find( rName );
-    if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey )
+    Index lKey = Find( rName );
+    if( lKey == IndexNotFound )
     {
         RscFile * pFName = new RscFile();
         pFName->aFileName = rName;
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 8d7ed1c..4bd05bb 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -19,14 +19,14 @@
 
 #include <tools/unqidx.hxx>
 
-sal_uIntPtr UniqueIndexImpl::Insert( void* p )
+UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
 {
     // NULL-Pointer not allowed
     if ( !p )
-        return UNIQUEINDEX_ENTRY_NOTFOUND;
+        return IndexNotFound;
 
    // Expend array if full
-    sal_uIntPtr nTmp = maMap.size();
+    Index nTmp = static_cast<Index>(maMap.size());
     if( nTmp == nCount )
         nTmp++;
 
@@ -45,7 +45,7 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p )
     return ( nUniqIndex + nStartIndex - 1 );
 }
 
-void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
+void* UniqueIndexImpl::Remove( Index nIndex )
 {
     // Check for valid index
     if ( (nIndex >= nStartIndex) &&
@@ -53,7 +53,7 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
     {
         // insert index as empty entry, and reduce indexcount,
         // if this entry was used
-        std::map<sal_uInt32, void*>::iterator it = maMap.find( nIndex - nStartIndex );
+        std::map<Index, void*>::iterator it = maMap.find( nIndex - nStartIndex );
         if( it != maMap.end() )
         {
             void* p = it->second;
@@ -65,52 +65,52 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
     return nullptr;
 }
 
-void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
+void* UniqueIndexImpl::Get( Index nIndex ) const
 {
     // check for valid index
     if ( (nIndex >= nStartIndex) &&
          (nIndex < (maMap.size() + nStartIndex)) )
     {
-        std::map<sal_uInt32, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
+        std::map<Index, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
         if( it != maMap.end() )
             return it->second;
     }
     return nullptr;
 }
 
-sal_uIntPtr UniqueIndexImpl::FirstIndex() const
+UniqueIndexImpl::Index UniqueIndexImpl::FirstIndex() const
 {
     if ( maMap.empty() )
-        return UNIQUEINDEX_ENTRY_NOTFOUND;
+        return IndexNotFound;
 
     return maMap.begin()->first;
 }
 
-sal_uIntPtr UniqueIndexImpl::LastIndex() const
+UniqueIndexImpl::Index UniqueIndexImpl::LastIndex() const
 {
     if ( maMap.empty() )
-        return UNIQUEINDEX_ENTRY_NOTFOUND;
+        return IndexNotFound;
 
     return maMap.rbegin()->first;
 }
 
-sal_uIntPtr UniqueIndexImpl::NextIndex(sal_uIntPtr aIndex) const
+UniqueIndexImpl::Index UniqueIndexImpl::NextIndex(Index aIndex) const
 {
     std::map<sal_uInt32, void*>::const_iterator it = maMap.find( aIndex );
     if ( it == maMap.end() )
-        return UNIQUEINDEX_ENTRY_NOTFOUND;
+        return IndexNotFound;
     ++it;
     if ( it == maMap.end() )
-        return UNIQUEINDEX_ENTRY_NOTFOUND;
+        return IndexNotFound;
     return it->first;
 }
 
-sal_uIntPtr UniqueIndexImpl::GetIndexOf(void* p) const
+UniqueIndexImpl::Index UniqueIndexImpl::GetIndexOf(void* p) const
 {
     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;
+    return IndexNotFound;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx
index 4e44784..47dc22e 100644
--- a/tools/source/ref/pstm.cxx
+++ b/tools/source/ref/pstm.cxx
@@ -51,7 +51,7 @@ SvCreateInstancePersist SvClassManager::Get( sal_Int32 nClassId )
              (cf. <SvPersistStream::SetStream>).
     @see SvPersistStream::SetStream
 */
-SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream, sal_uInt32 nStartIdxP )
+SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream, Index nStartIdxP )
     : rClassMgr( rMgr )
     , pStm( pStream )
     , aPUIdx( nStartIdxP )
@@ -135,7 +135,7 @@ void SvPersistStream::FlushData()
 {
 }
 
-sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
+SvPersistStream::Index SvPersistStream::GetIndex( SvPersistBase * pObj ) const
 {
     PersistBaseMap::const_iterator it = aPTable.find( pObj );
     if( it == aPTable.end() )
@@ -148,7 +148,7 @@ sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
     return it->second;
 }
 
-SvPersistBase * SvPersistStream::GetObject( sal_uIntPtr nIdx ) const
+SvPersistBase * SvPersistStream::GetObject( Index nIdx ) const
 {
     if( nIdx >= nStartIdx )
         return aPUIdx.Get( nIdx );
@@ -388,7 +388,7 @@ static void ReadId
 (
     SvStream & rStm,
     sal_uInt8 & nHdr,
-    sal_uInt32 & nId,
+    SvPersistStream::Index & nId,
     sal_uInt16 & nClassId
 )
 {
@@ -441,7 +441,7 @@ SvPersistStream& SvPersistStream::WritePointer
 
     if( pObj )
     {
-        sal_uIntPtr nId = GetIndex( pObj );
+        Index nId = GetIndex( pObj );
         if( nId )
             nP |= P_ID;
         else
@@ -468,7 +468,7 @@ void SvPersistStream::ReadObj
 )
 {
     sal_uInt8   nHdr;
-    sal_uInt32  nId = 0;
+    Index       nId = 0;
     sal_uInt16  nClassId;
 
     rpObj = nullptr; // specification: 0 in case of error
@@ -512,7 +512,7 @@ void SvPersistStream::ReadObj
             if( bRegister )
             {
                 // insert into table
-                sal_uIntPtr nNewId = aPUIdx.Insert( rpObj );
+                const Index nNewId = aPUIdx.Insert( rpObj );
                 // in order to restore state after saving
                 aPTable[ rpObj ] = nNewId;
                 DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId,
commit 4845155e0126571e4176819c5f27b76160146ce0
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Feb 1 20:17:13 2016 +0100

    UniqueIndexImpl::size() is unneeded
    
    Change-Id: I36c4d80ecf3ba3c88c98f5ad0a3fc1728332b25b

diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index 47da311..03a30c6 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -38,8 +38,6 @@ public:
         : 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*         Remove( sal_uIntPtr aIndex );
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 38b9cc9..8d7ed1c 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -49,7 +49,7 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex )
 {
     // Check for valid index
     if ( (nIndex >= nStartIndex) &&
-         (nIndex < (size() + nStartIndex)) )
+         (nIndex < (maMap.size() + nStartIndex)) )
     {
         // insert index as empty entry, and reduce indexcount,
         // if this entry was used
@@ -69,7 +69,7 @@ void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const
 {
     // check for valid index
     if ( (nIndex >= nStartIndex) &&
-         (nIndex < (size() + nStartIndex)) )
+         (nIndex < (maMap.size() + nStartIndex)) )
     {
         std::map<sal_uInt32, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
         if( it != maMap.end() )


More information about the Libreoffice-commits mailing list