[Libreoffice-commits] core.git: 4 commits - include/tools tools/source
Matteo Casalin
matteo.casalin at yahoo.com
Sat Mar 5 10:32:26 UTC 2016
include/tools/unqidx.hxx | 3 +--
tools/source/memtools/unqidx.cxx | 20 +++++---------------
2 files changed, 6 insertions(+), 17 deletions(-)
New commits:
commit f04999cc84152ef9fc216d339da4b5fc2c52e256
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Mar 5 10:05:50 2016 +0100
Delete obsolete/unuseful comments
Change-Id: Iadec409743e144a97c4468052dc0a04b91ca9619
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 7d7ac85..ecc6232 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -25,7 +25,6 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
if ( !p )
return IndexNotFound;
- // Expend array if full
const Index nTmp = static_cast<Index>(maMap.size()) + 1;
// Avoid overflow of UniqIndex upon deletion
@@ -35,7 +34,6 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
while ( maMap.find( nUniqIndex ) != maMap.end() )
nUniqIndex = (nUniqIndex+1) % nTmp;
- // Insert object to array
maMap[ nUniqIndex ] = p;
nUniqIndex++;
@@ -47,8 +45,6 @@ void* UniqueIndexImpl::Remove( Index nIndex )
// Check for valid index
if ( nIndex >= nStartIndex )
{
- // insert index as empty entry, and reduce indexcount,
- // if this entry was used
std::map<Index, void*>::iterator it = maMap.find( nIndex - nStartIndex );
if( it != maMap.end() )
{
commit ae35981823114d51376bf86bf1db665db62482c3
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Sat Mar 5 09:48:11 2016 +0100
Do not duplicate count of items
Change-Id: I373b39f36fee7c37f2c10cc748f309412d68b688
diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx
index 190b8e1..b6d65b4 100644
--- a/include/tools/unqidx.hxx
+++ b/include/tools/unqidx.hxx
@@ -33,12 +33,11 @@ private:
std::map<Index, void*> maMap;
const Index nStartIndex;
Index nUniqIndex;
- Index nCount;
public:
UniqueIndexImpl( Index _nStartIndex = 0 )
: maMap(),
- nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
+ nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex) {}
Index Insert( void* p );
// insert value with key, replacing existing entry if necessary
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index ea3b773..7d7ac85 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -26,9 +26,7 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
return IndexNotFound;
// Expend array if full
- Index nTmp = static_cast<Index>(maMap.size());
- if( nTmp == nCount )
- nTmp++;
+ const Index nTmp = static_cast<Index>(maMap.size()) + 1;
// Avoid overflow of UniqIndex upon deletion
nUniqIndex = nUniqIndex % nTmp;
@@ -40,7 +38,6 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
// Insert object to array
maMap[ nUniqIndex ] = p;
- nCount++;
nUniqIndex++;
return ( nUniqIndex + nStartIndex - 1 );
}
@@ -57,7 +54,6 @@ void* UniqueIndexImpl::Remove( Index nIndex )
{
void* p = it->second;
maMap.erase( it );
- nCount--;
return p;
}
}
commit 9f7f577df3bc056c77d63aafa26e4d21c53af0aa
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Mar 4 23:19:09 2016 +0100
Let find fail, instead of using a dubious upper bound check
Change-Id: I874ef402d241aa4de02057ca9dc747ae0497b1e0
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 3d60fb8..ea3b773 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -48,8 +48,7 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
void* UniqueIndexImpl::Remove( Index nIndex )
{
// Check for valid index
- if ( (nIndex >= nStartIndex) &&
- (nIndex < (maMap.size() + nStartIndex)) )
+ if ( nIndex >= nStartIndex )
{
// insert index as empty entry, and reduce indexcount,
// if this entry was used
@@ -68,8 +67,7 @@ void* UniqueIndexImpl::Remove( Index nIndex )
void* UniqueIndexImpl::Get( Index nIndex ) const
{
// check for valid index
- if ( (nIndex >= nStartIndex) &&
- (nIndex < (maMap.size() + nStartIndex)) )
+ if ( nIndex >= nStartIndex )
{
std::map<Index, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
if( it != maMap.end() )
commit 1d4914e9e5cad4f443a742a34862620143176dbc
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Fri Mar 4 23:10:50 2016 +0100
Use Index consistently
Change-Id: I20b7c1bd2ecccc21967c4edab37a94c971aa8a8d
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index 4bd05bb..3d60fb8 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -96,7 +96,7 @@ UniqueIndexImpl::Index UniqueIndexImpl::LastIndex() const
UniqueIndexImpl::Index UniqueIndexImpl::NextIndex(Index aIndex) const
{
- std::map<sal_uInt32, void*>::const_iterator it = maMap.find( aIndex );
+ std::map<Index, void*>::const_iterator it = maMap.find( aIndex );
if ( it == maMap.end() )
return IndexNotFound;
++it;
@@ -107,7 +107,7 @@ UniqueIndexImpl::Index UniqueIndexImpl::NextIndex(Index aIndex) const
UniqueIndexImpl::Index UniqueIndexImpl::GetIndexOf(void* p) const
{
- for( std::map<sal_uInt32, void*>::const_iterator it = maMap.begin(); it != maMap.end(); ++it )
+ for( std::map<Index, void*>::const_iterator it = maMap.begin(); it != maMap.end(); ++it )
if( it->second == p )
return it->first;
return IndexNotFound;
More information about the Libreoffice-commits
mailing list