diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 15:36:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 19:04:20 +0200 |
commit | 1fac487cfbb1d6c0bb1b3ccdfe44c4645c7e087e (patch) | |
tree | b8d87e56f79a5da32590d786d163bca17ae1bbeb /sw | |
parent | ea5d4bab6c54432bf590f8650d9f5ea930a0daaa (diff) |
use sal_Int32 in BigPtrArray
now that it's only use-case is also using sal_Int32
Change-Id: I9c51bb8fd6b8f5713b84b1a1f0a216e676a73299
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123995
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/bparr.hxx | 22 | ||||
-rw-r--r-- | sw/qa/core/Test-BigPtrArray.cxx | 76 | ||||
-rw-r--r-- | sw/source/core/bastyp/bparr.cxx | 24 |
3 files changed, 61 insertions, 61 deletions
diff --git a/sw/inc/bparr.hxx b/sw/inc/bparr.hxx index d28e964685d7..f4c1c47d6da1 100644 --- a/sw/inc/bparr.hxx +++ b/sw/inc/bparr.hxx @@ -41,7 +41,7 @@ public: virtual ~BigPtrEntry() = default; BigPtrEntry & operator =(BigPtrEntry const &) = default; - inline sal_uLong GetPos() const; + inline sal_Int32 GetPos() const; inline BigPtrArray& GetArray() const; }; @@ -59,7 +59,7 @@ struct BlockInfo final BigPtrArray* pBigArr; ///< in this array the block is located std::array<BigPtrEntry*, MAXENTRY> mvData; ///< data block - sal_uLong nStart, nEnd; ///< start- and end index + sal_Int32 nStart, nEnd; ///< start- and end index sal_uInt16 nElem; ///< number of elements }; @@ -68,13 +68,13 @@ class SW_DLLPUBLIC BigPtrArray protected: std::unique_ptr<BlockInfo*[]> m_ppInf; ///< block info - sal_uLong m_nSize; ///< number of elements + sal_Int32 m_nSize; ///< number of elements sal_uInt16 m_nMaxBlock; ///< current max. number of blocks sal_uInt16 m_nBlock; ///< number of blocks mutable sal_uInt16 m_nCur; ///< last used block - sal_uInt16 Index2Block( sal_uLong ) const; ///< block search + sal_uInt16 Index2Block( sal_Int32 ) const; ///< block search BlockInfo* InsBlock( sal_uInt16 ); ///< insert block void BlockDel( sal_uInt16 ); ///< some blocks were deleted void UpdIndex( sal_uInt16 ); ///< recalculate indices @@ -86,17 +86,17 @@ public: BigPtrArray(); ~BigPtrArray(); - sal_uLong Count() const { return m_nSize; } + sal_Int32 Count() const { return m_nSize; } - void Insert( BigPtrEntry* p, sal_uLong pos ); - void Remove( sal_uLong pos, sal_uLong n = 1 ); - void Move( sal_uLong from, sal_uLong to ); - void Replace( sal_uLong pos, BigPtrEntry* p); + void Insert( BigPtrEntry* p, sal_Int32 pos ); + void Remove( sal_Int32 pos, sal_Int32 n = 1 ); + void Move( sal_Int32 from, sal_Int32 to ); + void Replace( sal_Int32 pos, BigPtrEntry* p); - BigPtrEntry* operator[]( sal_uLong ) const; + BigPtrEntry* operator[]( sal_Int32 ) const; }; -inline sal_uLong BigPtrEntry::GetPos() const +inline sal_Int32 BigPtrEntry::GetPos() const { assert(this == m_pBlock->mvData[ m_nOffset ]); // element not in the block return m_pBlock->nStart + m_nOffset; diff --git a/sw/qa/core/Test-BigPtrArray.cxx b/sw/qa/core/Test-BigPtrArray.cxx index 3234b26f17eb..6754cda04007 100644 --- a/sw/qa/core/Test-BigPtrArray.cxx +++ b/sw/qa/core/Test-BigPtrArray.cxx @@ -27,38 +27,38 @@ namespace /* private */ { - const sal_uLong NUM_ENTRIES = 10; + const sal_Int32 NUM_ENTRIES = 10; class BigPtrEntryMock : public BigPtrEntry { public: - explicit BigPtrEntryMock(sal_uLong count) : count_(count) + explicit BigPtrEntryMock(sal_Int32 count) : count_(count) { } - sal_uLong getCount() const + sal_Int32 getCount() const { return count_; } - sal_uLong Position() const + sal_Int32 Position() const { return GetPos(); } private: - sal_uLong count_; + sal_Int32 count_; }; - void fillBigPtrArray(BigPtrArray& bparr, sal_uLong numEntries) + void fillBigPtrArray(BigPtrArray& bparr, sal_Int32 numEntries) { - for (sal_uLong i = 0; i < numEntries; i++) + for (sal_Int32 i = 0; i < numEntries; i++) bparr.Insert(new BigPtrEntryMock(i), bparr.Count()); } bool checkElementPositions(const BigPtrArray& bparr) { - for (sal_uLong i = 0; i < bparr.Count(); i++) + for (sal_Int32 i = 0; i < bparr.Count(); i++) { if (static_cast<BigPtrEntryMock*>(bparr[i])->Position() != i) return false; @@ -68,7 +68,7 @@ namespace /* private */ void releaseBigPtrArrayContent(BigPtrArray const & bparr) { - for (sal_uLong i = 0; i < bparr.Count(); i++) + for (sal_Int32 i = 0; i < bparr.Count(); i++) delete bparr[i]; } } @@ -93,7 +93,7 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE ( "BigPtrArray ctor failed", - static_cast<sal_uLong>(0), bparr.Count() + static_cast<sal_Int32>(0), bparr.Count() ); } @@ -101,9 +101,9 @@ public: { BigPtrArray bparr; - for (sal_uLong i = 0; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES; i++) { - sal_uLong oldCount = bparr.Count(); + sal_Int32 oldCount = bparr.Count(); bparr.Insert(new BigPtrEntryMock(i), 0); CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -112,7 +112,7 @@ public: ); } - for (sal_uLong i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--) + for (sal_Int32 i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -136,7 +136,7 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - sal_uLong oldCount = bparr.Count(); + sal_Int32 oldCount = bparr.Count(); bparr.Insert(new BigPtrEntryMock(NUM_ENTRIES), bparr.Count() / 2); @@ -166,10 +166,10 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - const sal_uLong oldCount = bparr.Count(); + const sal_Int32 oldCount = bparr.Count(); // insert 5 elements - for (sal_uLong i = 0, j = 30; i < 5; i++, j++) + for (sal_Int32 i = 0, j = 30; i < 5; i++, j++) bparr.Insert(new BigPtrEntryMock(j), i); CPPUNIT_ASSERT_EQUAL_MESSAGE @@ -180,7 +180,7 @@ public: // now, first 5 elements have counts: 30,31,..34 // next 10 elements have counts: 0,1,..9 - for (sal_uLong i = 0, j = 30; i < bparr.Count(); i++, j++) + for (sal_Int32 i = 0, j = 30; i < bparr.Count(); i++, j++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -204,7 +204,7 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - sal_uLong oldCount = bparr.Count(); + sal_Int32 oldCount = bparr.Count(); bparr.Insert(new BigPtrEntryMock(NUM_ENTRIES), bparr.Count()); CPPUNIT_ASSERT_EQUAL_MESSAGE @@ -233,9 +233,9 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - for (sal_uLong i = 0; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES; i++) { - sal_uLong oldCount = bparr.Count(); + sal_Int32 oldCount = bparr.Count(); delete bparr[0]; // release content bparr.Remove(0); // remove item from container @@ -246,7 +246,7 @@ public: oldCount - 1, bparr.Count() ); - for (sal_uLong j = 0, k = i + 1; j < bparr.Count(); j++, k++) + for (sal_Int32 j = 0, k = i + 1; j < bparr.Count(); j++, k++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -271,7 +271,7 @@ public: for (int i = NUM_ENTRIES - 1; i >= 0; i--) { - sal_uLong oldCount = bparr.Count(); + sal_Int32 oldCount = bparr.Count(); delete bparr[i]; bparr.Remove(i); @@ -281,7 +281,7 @@ public: (oldCount - 1), bparr.Count() ); - for (sal_uLong j = 0; j < bparr.Count(); j++) + for (sal_Int32 j = 0; j < bparr.Count(); j++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -306,8 +306,8 @@ public: while (bparr.Count()) { - sal_uLong oldCount = bparr.Count(); - sal_uLong oldElement = static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount(); + sal_Int32 oldCount = bparr.Count(); + sal_Int32 oldElement = static_cast<BigPtrEntryMock*>(bparr[bparr.Count() / 2])->getCount(); delete bparr[bparr.Count() / 2]; bparr.Remove(bparr.Count() / 2); @@ -318,7 +318,7 @@ public: oldCount - 1, bparr.Count() ); - for (sal_uLong i = 0; i < bparr.Count(); i++) + for (sal_Int32 i = 0; i < bparr.Count(); i++) { CPPUNIT_ASSERT_MESSAGE ( @@ -343,10 +343,10 @@ public: while(bparr.Count()) { - sal_uLong nRemove = std::min<sal_uLong>(bparr.Count(), 3); - sal_uLong oldCount = bparr.Count(); + sal_Int32 nRemove = std::min<sal_Int32>(bparr.Count(), 3); + sal_Int32 oldCount = bparr.Count(); - for (sal_uLong i = 0; i < nRemove; i++) + for (sal_Int32 i = 0; i < nRemove; i++) delete bparr[i]; bparr.Remove(0, nRemove); @@ -377,7 +377,7 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE ( "test_remove_all_elements_at_once failed", - static_cast<sal_uLong>(0), bparr.Count() + static_cast<sal_Int32>(0), bparr.Count() ); } @@ -387,12 +387,12 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - for (sal_uLong i = 0; i < NUM_ENTRIES - 1; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES - 1; i++) { bparr.Move(i, i + 2); } - for (sal_uLong i = 0; i < (NUM_ENTRIES - 1); i++) + for (sal_Int32 i = 0; i < (NUM_ENTRIES - 1); i++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -404,7 +404,7 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE ( "test_move_elements_from_lower_to_higher_pos failed", - static_cast<sal_uLong>(0), static_cast<BigPtrEntryMock*>(bparr[NUM_ENTRIES -1])->getCount() + static_cast<sal_Int32>(0), static_cast<BigPtrEntryMock*>(bparr[NUM_ENTRIES -1])->getCount() ); CPPUNIT_ASSERT_MESSAGE @@ -433,7 +433,7 @@ public: (NUM_ENTRIES - 1), static_cast<BigPtrEntryMock*>(bparr[0])->getCount() ); - for (sal_uLong i = 1; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 1; i < NUM_ENTRIES; i++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -457,12 +457,12 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - for (sal_uLong i = 0; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES; i++) { bparr.Move(i, i); } - for (sal_uLong i = 0; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES; i++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( @@ -486,13 +486,13 @@ public: fillBigPtrArray(bparr, NUM_ENTRIES); - for (sal_uLong i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--) + for (sal_Int32 i = 0, j = NUM_ENTRIES - 1; i < NUM_ENTRIES; i++, j--) { delete bparr[i]; bparr.Replace(i, new BigPtrEntryMock(j)); } - for (sal_uLong i = 0; i < NUM_ENTRIES; i++) + for (sal_Int32 i = 0; i < NUM_ENTRIES; i++) { CPPUNIT_ASSERT_EQUAL_MESSAGE ( diff --git a/sw/source/core/bastyp/bparr.cxx b/sw/source/core/bastyp/bparr.cxx index 6b7aa28edb44..b99385bfd3dc 100644 --- a/sw/source/core/bastyp/bparr.cxx +++ b/sw/source/core/bastyp/bparr.cxx @@ -28,11 +28,11 @@ const sal_uInt16 nBlockGrowSize = 20; #if OSL_DEBUG_LEVEL > 2 #define CHECKIDX( p, n, i, c ) CheckIdx( p, n, i, c ); -void CheckIdx( BlockInfo** ppInf, sal_uInt16 nBlock, sal_uLong nSize, sal_uInt16 nCur ) +void CheckIdx( BlockInfo** ppInf, sal_uInt16 nBlock, sal_Int32 nSize, sal_uInt16 nCur ) { assert( !nSize || nCur < nBlock ); // BigPtrArray: CurIndex invalid - sal_uLong nIdx = 0; + sal_Int32 nIdx = 0; for( sal_uInt16 nCnt = 0; nCnt < nBlock; ++nCnt, ++ppInf ) { nIdx += (*ppInf)->nElem; @@ -67,7 +67,7 @@ BigPtrArray::~BigPtrArray() // Also moving is done simply here. Optimization is useless because of the // division of this field into multiple parts. -void BigPtrArray::Move( sal_uLong from, sal_uLong to ) +void BigPtrArray::Move( sal_Int32 from, sal_Int32 to ) { if (from != to) { @@ -79,7 +79,7 @@ void BigPtrArray::Move( sal_uLong from, sal_uLong to ) } } -BigPtrEntry* BigPtrArray::operator[]( sal_uLong idx ) const +BigPtrEntry* BigPtrArray::operator[]( sal_Int32 idx ) const { assert(idx < m_nSize); // operator[]: Index out of bounds m_nCur = Index2Block( idx ); @@ -88,7 +88,7 @@ BigPtrEntry* BigPtrArray::operator[]( sal_uLong idx ) const } /** Search a block at a given position */ -sal_uInt16 BigPtrArray::Index2Block( sal_uLong pos ) const +sal_uInt16 BigPtrArray::Index2Block( sal_Int32 pos ) const { // last used block? BlockInfo* p = m_ppInf[ m_nCur ]; @@ -138,7 +138,7 @@ sal_uInt16 BigPtrArray::Index2Block( sal_uLong pos ) const void BigPtrArray::UpdIndex( sal_uInt16 pos ) { BlockInfo** pp = m_ppInf.get() + pos; - sal_uLong idx = (*pp)->nEnd + 1; + sal_Int32 idx = (*pp)->nEnd + 1; while( ++pos < m_nBlock ) { BlockInfo* p = *++pp; @@ -198,7 +198,7 @@ void BigPtrArray::BlockDel( sal_uInt16 nDel ) } } -void BigPtrArray::Insert( BigPtrEntry* pElem, sal_uLong pos ) +void BigPtrArray::Insert( BigPtrEntry* pElem, sal_Int32 pos ) { CHECKIDX( m_ppInf.get(), m_nBlock, m_nSize, m_nCur ); @@ -303,7 +303,7 @@ void BigPtrArray::Insert( BigPtrEntry* pElem, sal_uLong pos ) CHECKIDX( m_ppInf.get(), m_nBlock, m_nSize, m_nCur ); } -void BigPtrArray::Remove( sal_uLong pos, sal_uLong n ) +void BigPtrArray::Remove( sal_Int32 pos, sal_Int32 n ) { CHECKIDX( m_ppInf.get(), m_nBlock, m_nSize, m_nCur ); @@ -314,14 +314,14 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n ) BlockInfo* p = m_ppInf[ cur ]; pos -= p->nStart; - sal_uLong nElem = n; + sal_Int32 nElem = n; while( nElem ) { sal_uInt16 nel = p->nElem - sal_uInt16(pos); - if( sal_uLong(nel) > nElem ) + if( sal_Int32(nel) > nElem ) nel = sal_uInt16(nElem); // move elements if needed - if( ( pos + nel ) < sal_uLong(p->nElem) ) + if( ( pos + nel ) < sal_Int32(p->nElem) ) { auto pTo = p->mvData.begin() + pos; auto pFrom = pTo + nel; @@ -387,7 +387,7 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n ) CHECKIDX( m_ppInf.get(), m_nBlock, m_nSize, m_nCur ); } -void BigPtrArray::Replace( sal_uLong idx, BigPtrEntry* pElem) +void BigPtrArray::Replace( sal_Int32 idx, BigPtrEntry* pElem) { assert(idx < m_nSize); // Index out of bounds m_nCur = Index2Block( idx ); |