summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2016-03-05 18:58:30 +0100
committerNoel Grandin <noelgrandin@gmail.com>2016-03-06 06:40:41 +0000
commit96be131c5ef00bfae3c0c83231989fdfe9f7f5bb (patch)
tree6a960618ae9b8164934f87df5cea002660a126a7 /tools
parent078188793b2753bf607bb629464935ccefd28136 (diff)
Minor optimization, and improved comments
Change-Id: I6732725ef48d69f4c01762a117a60447e313aea0 Reviewed-on: https://gerrit.libreoffice.org/22936 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/memtools/unqidx.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx
index b53895fdfce2..7c57c1b4f3fe 100644
--- a/tools/source/memtools/unqidx.cxx
+++ b/tools/source/memtools/unqidx.cxx
@@ -25,13 +25,13 @@ UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p )
if ( !p )
return IndexNotFound;
- // Search next unused index, may be needed after
- // a removal followed by multiple insertions
- while ( maMap.find( nUniqIndex ) != maMap.end() )
+ // Insert the pointer, starting from the current nUniqIndex "hint"
+ // and increasing it until a free one is found (this may happen
+ // after removals followed by multiple insertions).
+ while ( !maMap.emplace(nUniqIndex, p).second )
++nUniqIndex;
- maMap[ nUniqIndex ] = p;
-
+ // Take care of updating hint key for next insertion
return nUniqIndex++;
}