[Libreoffice-commits] core.git: tools/source

Matteo Casalin matteo.casalin at yahoo.com
Sun Mar 6 06:41:00 UTC 2016


 tools/source/memtools/unqidx.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 96be131c5ef00bfae3c0c83231989fdfe9f7f5bb
Author: Matteo Casalin <matteo.casalin at yahoo.com>
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 <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

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++;
 }
 


More information about the Libreoffice-commits mailing list