tools/source/memtools/unqidx.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
New commits: commit 96be131c5ef00bfae3c0c83231989fdfe9f7f5bb Author: Matteo Casalin <[email protected]> Date: Sat Mar 5 18:58:30 2016 +0100 Minor optimization, and improved comments Change-Id: I6732725ef48d69f4c01762a117a60447e313aea0 Reviewed-on: https://gerrit.libreoffice.org/22936 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx index b53895f..7c57c1b 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++; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
