[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Nov 28 12:47:53 UTC 2016


 sw/inc/bparr.hxx                 |   12 +--
 sw/source/core/bastyp/bparr.cxx  |  146 +++++++++++++++++++--------------------
 sw/source/core/docnode/nodes.cxx |    6 -
 3 files changed, 82 insertions(+), 82 deletions(-)

New commits:
commit 1ca67dcaefe794c683b99382ba8bac0f736a7f0b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Nov 28 11:07:02 2016 +0100

    sw: prefix members of BigPtrArray
    
    Change-Id: I87a91fad09616add823e7e556597419d02e43c6c
    Reviewed-on: https://gerrit.libreoffice.org/31311
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/inc/bparr.hxx b/sw/inc/bparr.hxx
index 9ec8c91..53a3f18 100644
--- a/sw/inc/bparr.hxx
+++ b/sw/inc/bparr.hxx
@@ -61,12 +61,12 @@ struct BlockInfo {                  // block info:
 class SW_DLLPUBLIC BigPtrArray
 {
 protected:
-    BlockInfo**     ppInf;              // block info
-    sal_uLong       nSize;              ///< number of elements
-    sal_uInt16      nMaxBlock;          ///< current max. number of blocks
-    sal_uInt16      nBlock;             ///< number of blocks
+    BlockInfo**     m_ppInf;              // block info
+    sal_uLong       m_nSize;              ///< number of elements
+    sal_uInt16      m_nMaxBlock;          ///< current max. number of blocks
+    sal_uInt16      m_nBlock;             ///< number of blocks
     mutable
-        sal_uInt16  nCur;               ///< last used block
+        sal_uInt16  m_nCur;               ///< last used block
 
     sal_uInt16  Index2Block( sal_uLong ) const; ///< block search
     BlockInfo*  InsBlock( sal_uInt16 );         ///< insert block
@@ -80,7 +80,7 @@ public:
     BigPtrArray();
     ~BigPtrArray();
 
-    sal_uLong Count() const { return nSize; }
+    sal_uLong Count() const { return m_nSize; }
 
     void Insert( const ElementPtr& r, sal_uLong pos );
     void Remove( sal_uLong pos, sal_uLong n = 1 );
diff --git a/sw/source/core/bastyp/bparr.cxx b/sw/source/core/bastyp/bparr.cxx
index f5e3166..f4cd902 100644
--- a/sw/source/core/bastyp/bparr.cxx
+++ b/sw/source/core/bastyp/bparr.cxx
@@ -47,24 +47,24 @@ void CheckIdx( BlockInfo** ppInf, sal_uInt16 nBlock, sal_uLong nSize, sal_uInt16
 
 BigPtrArray::BigPtrArray()
 {
-    nBlock = nCur = 0;
-    nSize = 0;
-    nMaxBlock = nBlockGrowSize;
-    ppInf = new BlockInfo* [ nMaxBlock ];
+    m_nBlock = m_nCur = 0;
+    m_nSize = 0;
+    m_nMaxBlock = nBlockGrowSize;
+    m_ppInf = new BlockInfo* [ m_nMaxBlock ];
 }
 
 BigPtrArray::~BigPtrArray()
 {
-    if( nBlock )
+    if( m_nBlock )
     {
-        BlockInfo** pp = ppInf;
-        for( sal_uInt16 n = 0; n < nBlock; ++n, ++pp )
+        BlockInfo** pp = m_ppInf;
+        for( sal_uInt16 n = 0; n < m_nBlock; ++n, ++pp )
         {
             delete[] (*pp)->pData;
             delete    *pp;
         }
     }
-    delete[] ppInf;
+    delete[] m_ppInf;
 }
 
 // Also moving is done simply here. Optimization is useless because of the
@@ -74,7 +74,7 @@ void BigPtrArray::Move( sal_uLong from, sal_uLong to )
     if (from != to)
     {
         sal_uInt16 cur = Index2Block( from );
-        BlockInfo* p = ppInf[ cur ];
+        BlockInfo* p = m_ppInf[ cur ];
         ElementPtr pElem = p->pData[ from - p->nStart ];
         Insert( pElem, to ); // insert first, then delete!
         Remove( ( to < from ) ? ( from + 1 ) : from );
@@ -83,9 +83,9 @@ void BigPtrArray::Move( sal_uLong from, sal_uLong to )
 
 ElementPtr BigPtrArray::operator[]( sal_uLong idx ) const
 {
-    assert(idx < nSize); // operator[]: Index out of bounds
-    nCur = Index2Block( idx );
-    BlockInfo* p = ppInf[ nCur ];
+    assert(idx < m_nSize); // operator[]: Index out of bounds
+    m_nCur = Index2Block( idx );
+    BlockInfo* p = m_ppInf[ m_nCur ];
     return p->pData[ idx - p->nStart ];
 }
 
@@ -93,36 +93,36 @@ ElementPtr BigPtrArray::operator[]( sal_uLong idx ) const
 sal_uInt16 BigPtrArray::Index2Block( sal_uLong pos ) const
 {
     // last used block?
-    BlockInfo* p = ppInf[ nCur ];
+    BlockInfo* p = m_ppInf[ m_nCur ];
     if( p->nStart <= pos && p->nEnd >= pos )
-        return nCur;
+        return m_nCur;
     // Index = 0?
     if( !pos )
         return 0;
 
     // following one?
-    if( nCur < ( nBlock - 1 ) )
+    if( m_nCur < ( m_nBlock - 1 ) )
     {
-        p = ppInf[ nCur+1 ];
+        p = m_ppInf[ m_nCur+1 ];
         if( p->nStart <= pos && p->nEnd >= pos )
-            return nCur+1;
+            return m_nCur+1;
     }
     // previous one?
-    else if( pos < p->nStart && nCur > 0 )
+    else if( pos < p->nStart && m_nCur > 0 )
     {
-        p = ppInf[ nCur-1 ];
+        p = m_ppInf[ m_nCur-1 ];
         if( p->nStart <= pos && p->nEnd >= pos )
-            return nCur-1;
+            return m_nCur-1;
     }
 
     // binary search: always successful
-    sal_uInt16 lower = 0, upper = nBlock - 1;
+    sal_uInt16 lower = 0, upper = m_nBlock - 1;
     sal_uInt16 cur = 0;
     for(;;)
     {
         sal_uInt16 n = lower + ( upper - lower ) / 2;
         cur = ( n == cur ) ? n+1 : n;
-        p = ppInf[ cur ];
+        p = m_ppInf[ cur ];
         if( p->nStart <= pos && p->nEnd >= pos )
             return cur;
 
@@ -139,9 +139,9 @@ sal_uInt16 BigPtrArray::Index2Block( sal_uLong pos ) const
 */
 void BigPtrArray::UpdIndex( sal_uInt16 pos )
 {
-    BlockInfo** pp = ppInf + pos;
+    BlockInfo** pp = m_ppInf + pos;
     sal_uLong idx = (*pp)->nEnd + 1;
-    while( ++pos < nBlock )
+    while( ++pos < m_nBlock )
     {
         BlockInfo* p = *++pp;
         p->nStart = idx;
@@ -158,26 +158,26 @@ void BigPtrArray::UpdIndex( sal_uInt16 pos )
 */
 BlockInfo* BigPtrArray::InsBlock( sal_uInt16 pos )
 {
-    if( nBlock == nMaxBlock )
+    if( m_nBlock == m_nMaxBlock )
     {
         // than extend the array first
-        BlockInfo** ppNew = new BlockInfo* [ nMaxBlock + nBlockGrowSize ];
-        memcpy( ppNew, ppInf, nMaxBlock * sizeof( BlockInfo* ));
-        delete[] ppInf;
-        nMaxBlock += nBlockGrowSize;
-        ppInf = ppNew;
+        BlockInfo** ppNew = new BlockInfo* [ m_nMaxBlock + nBlockGrowSize ];
+        memcpy( ppNew, m_ppInf, m_nMaxBlock * sizeof( BlockInfo* ));
+        delete[] m_ppInf;
+        m_nMaxBlock += nBlockGrowSize;
+        m_ppInf = ppNew;
     }
-    if( pos != nBlock )
+    if( pos != m_nBlock )
     {
-        memmove( ppInf + pos+1, ppInf + pos,
-                 ( nBlock - pos ) * sizeof( BlockInfo* ));
+        memmove( m_ppInf + pos+1, m_ppInf + pos,
+                 ( m_nBlock - pos ) * sizeof( BlockInfo* ));
     }
-    ++nBlock;
+    ++m_nBlock;
     BlockInfo* p = new BlockInfo;
-    ppInf[ pos ] = p;
+    m_ppInf[ pos ] = p;
 
     if( pos )
-        p->nStart = p->nEnd = ppInf[ pos-1 ]->nEnd + 1;
+        p->nStart = p->nEnd = m_ppInf[ pos-1 ]->nEnd + 1;
     else
         p->nStart = p->nEnd = 0;
 
@@ -190,16 +190,16 @@ BlockInfo* BigPtrArray::InsBlock( sal_uInt16 pos )
 
 void BigPtrArray::BlockDel( sal_uInt16 nDel )
 {
-    nBlock = nBlock - nDel;
-    if( nMaxBlock - nBlock > nBlockGrowSize )
+    m_nBlock = m_nBlock - nDel;
+    if( m_nMaxBlock - m_nBlock > nBlockGrowSize )
     {
         // than shrink array
-        nDel = (( nBlock / nBlockGrowSize ) + 1 ) * nBlockGrowSize;
+        nDel = (( m_nBlock / nBlockGrowSize ) + 1 ) * nBlockGrowSize;
         BlockInfo** ppNew = new BlockInfo* [ nDel ];
-        memcpy( ppNew, ppInf, nBlock * sizeof( BlockInfo* ));
-        delete[] ppInf;
-        ppInf = ppNew;
-        nMaxBlock = nDel;
+        memcpy( ppNew, m_ppInf, m_nBlock * sizeof( BlockInfo* ));
+        delete[] m_ppInf;
+        m_ppInf = ppNew;
+        m_nMaxBlock = nDel;
     }
 }
 
@@ -209,16 +209,16 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos )
 
     BlockInfo* p;
     sal_uInt16 cur;
-    if( !nSize )
+    if( !m_nSize )
     {
         // special case: insert first element
         p = InsBlock( cur = 0 );
     }
-    else if( pos == nSize )
+    else if( pos == m_nSize )
     {
         // special case: insert at end
-        cur = nBlock - 1;
-        p = ppInf[ cur ];
+        cur = m_nBlock - 1;
+        p = m_ppInf[ cur ];
         if( p->nElem == MAXENTRY )
             // the last block is full, create a new one
             p = InsBlock( ++cur );
@@ -227,16 +227,16 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos )
     {
         // standard case:
         cur = Index2Block( pos );
-        p = ppInf[ cur ];
+        p = m_ppInf[ cur ];
     }
 
     if( p->nElem == MAXENTRY )
     {
         // does the last entry fit into the next block?
         BlockInfo* q;
-        if( cur < ( nBlock - 1 ) && ppInf[ cur+1 ]->nElem < MAXENTRY )
+        if( cur < ( m_nBlock - 1 ) && m_ppInf[ cur+1 ]->nElem < MAXENTRY )
         {
-            q = ppInf[ cur+1 ];
+            q = m_ppInf[ cur+1 ];
             if( q->nElem )
             {
                 int nCount = q->nElem;
@@ -253,7 +253,7 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos )
             // If it does not fit, then insert a new block. But if there is more
             // than 50% space in the array then compress first.
             if( /*nBlock == nMaxBlock &&*/
-                nBlock > ( nSize / ( MAXENTRY / 2 ) ) &&
+                m_nBlock > ( m_nSize / ( MAXENTRY / 2 ) ) &&
                 cur >= Compress() )
             {
                 // Something was moved before the current position and all
@@ -294,9 +294,9 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos )
     p->pData[ pos ] = rElem;
     p->nEnd++;
     p->nElem++;
-    nSize++;
-    if( cur != ( nBlock - 1 ) ) UpdIndex( cur );
-    nCur = cur;
+    m_nSize++;
+    if( cur != ( m_nBlock - 1 ) ) UpdIndex( cur );
+    m_nCur = cur;
 
     CHECKIDX( ppInf, nBlock, nSize, nCur );
 }
@@ -309,7 +309,7 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
     sal_uInt16 cur = Index2Block( pos ); // current block number
     sal_uInt16 nBlk1 = cur;              // 1st treated block
     sal_uInt16 nBlk1del = USHRT_MAX;     // 1st deleted block
-    BlockInfo* p = ppInf[ cur ];
+    BlockInfo* p = m_ppInf[ cur ];
     pos -= p->nStart;
 
     sal_uLong nElem = n;
@@ -344,7 +344,7 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
         nElem -= nel;
         if( !nElem )
             break;
-        p = ppInf[ ++cur ];
+        p = m_ppInf[ ++cur ];
         pos = 0;
     }
 
@@ -352,17 +352,17 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
     if( nBlkdel )
     {
         for( sal_uInt16 i = nBlk1del; i < ( nBlk1del + nBlkdel ); i++ )
-            delete ppInf[ i ];
+            delete m_ppInf[ i ];
 
-        if( ( nBlk1del + nBlkdel ) < nBlock )
+        if( ( nBlk1del + nBlkdel ) < m_nBlock )
         {
-            memmove( ppInf + nBlk1del, ppInf + nBlk1del + nBlkdel,
-                     ( nBlock - nBlkdel - nBlk1del ) * sizeof( BlockInfo* ) );
+            memmove( m_ppInf + nBlk1del, m_ppInf + nBlk1del + nBlkdel,
+                     ( m_nBlock - nBlkdel - nBlk1del ) * sizeof( BlockInfo* ) );
 
             // UpdateIdx updates the successor thus start before first elem
             if( !nBlk1 )
             {
-                p = ppInf[ 0 ];
+                p = m_ppInf[ 0 ];
                 p->nStart = 0;
                 p->nEnd = p->nElem-1;
             }
@@ -374,13 +374,13 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
         BlockDel( nBlkdel ); // blocks were deleted
     }
 
-    nSize -= n;
-    if( nBlk1 != ( nBlock - 1 ) && nSize )
+    m_nSize -= n;
+    if( nBlk1 != ( m_nBlock - 1 ) && m_nSize )
         UpdIndex( nBlk1 );
-    nCur = nBlk1;
+    m_nCur = nBlk1;
 
     // call Compress() if there is more than 50% space in the array
-    if( nBlock > ( nSize / ( MAXENTRY / 2 ) ) )
+    if( m_nBlock > ( m_nSize / ( MAXENTRY / 2 ) ) )
         Compress();
 
     CHECKIDX( ppInf, nBlock, nSize, nCur );
@@ -388,9 +388,9 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
 
 void BigPtrArray::Replace( sal_uLong idx, const ElementPtr& rElem)
 {
-    assert(idx < nSize); // Index out of bounds
-    nCur = Index2Block( idx );
-    BlockInfo* p = ppInf[ nCur ];
+    assert(idx < m_nSize); // Index out of bounds
+    m_nCur = Index2Block( idx );
+    BlockInfo* p = m_ppInf[ m_nCur ];
     rElem->nOffset = sal_uInt16(idx - p->nStart);
     rElem->pBlock = p;
     p->pData[ idx - p->nStart ] = rElem;
@@ -404,7 +404,7 @@ sal_uInt16 BigPtrArray::Compress()
     // Iterate over InfoBlock array from beginning to end. If there is a deleted
     // block in between so move all following ones accordingly. The pointer <pp>
     // represents the "old" and <qq> the "new" array.
-    BlockInfo** pp = ppInf, **qq = pp;
+    BlockInfo** pp = m_ppInf, **qq = pp;
     BlockInfo* p;
     BlockInfo* pLast(nullptr);                 // last empty block
     sal_uInt16 nLast = 0;                // missing elements
@@ -414,7 +414,7 @@ sal_uInt16 BigPtrArray::Compress()
     // convert fill percentage into number of remaining elements
     short nMax = MAXENTRY - (long) MAXENTRY * COMPRESSLVL / 100;
 
-    for( sal_uInt16 cur = 0; cur < nBlock; ++cur )
+    for( sal_uInt16 cur = 0; cur < m_nBlock; ++cur )
     {
         p = *pp++;
         sal_uInt16 n = p->nElem;
@@ -490,12 +490,12 @@ sal_uInt16 BigPtrArray::Compress()
         BlockDel( nBlkdel );
 
     // and re-index
-    p = ppInf[ 0 ];
+    p = m_ppInf[ 0 ];
     p->nEnd = p->nElem - 1;
     UpdIndex( 0 );
 
-    if( nCur >= nFirstChgPos )
-        nCur = 0;
+    if( m_nCur >= nFirstChgPos )
+        m_nCur = 0;
 
     CHECKIDX( ppInf, nBlock, nSize, nCur );
 
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 1e0b282..aec2552 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2179,13 +2179,13 @@ SwNode* SwNodes::FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
 void SwNodes::ForEach( sal_uLong nStart, sal_uLong nEnd,
                        FnForEach_SwNodes fn, void* pArgs )
 {
-    if( nEnd > nSize )
-        nEnd = nSize;
+    if( nEnd > m_nSize )
+        nEnd = m_nSize;
 
     if( nStart < nEnd )
     {
         sal_uInt16 cur = Index2Block( nStart );
-        BlockInfo** pp = ppInf + cur;
+        BlockInfo** pp = m_ppInf + cur;
         BlockInfo* p = *pp;
         sal_uInt16 nElem = sal_uInt16( nStart - p->nStart );
         ElementPtr* pElem = p->pData + nElem;


More information about the Libreoffice-commits mailing list