Let find fail, instead of using a dubious upper bound check

Change-Id: I874ef402d241aa4de02057ca9dc747ae0497b1e0
This commit is contained in:
Matteo Casalin
2016-03-04 23:19:09 +01:00
parent 1d4914e9e5
commit 9f7f577df3

View File

@@ -48,8 +48,7 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
void* UniqueIndexImpl::Remove( Index nIndex ) void* UniqueIndexImpl::Remove( Index nIndex )
{ {
// Check for valid index // Check for valid index
if ( (nIndex >= nStartIndex) && if ( nIndex >= nStartIndex )
(nIndex < (maMap.size() + nStartIndex)) )
{ {
// insert index as empty entry, and reduce indexcount, // insert index as empty entry, and reduce indexcount,
// if this entry was used // if this entry was used
@@ -68,8 +67,7 @@ void* UniqueIndexImpl::Remove( Index nIndex )
void* UniqueIndexImpl::Get( Index nIndex ) const void* UniqueIndexImpl::Get( Index nIndex ) const
{ {
// check for valid index // check for valid index
if ( (nIndex >= nStartIndex) && if ( nIndex >= nStartIndex )
(nIndex < (maMap.size() + nStartIndex)) )
{ {
std::map<Index, void*>::const_iterator it = maMap.find( nIndex - nStartIndex ); std::map<Index, void*>::const_iterator it = maMap.find( nIndex - nStartIndex );
if( it != maMap.end() ) if( it != maMap.end() )