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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 17 09:59:30 UTC 2019


 sc/source/core/data/documen2.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 4c2034b808fed4f9dfd715d8a4813e788a7e97a4
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu May 16 16:52:19 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 17 11:58:34 2019 +0200

    avoid two lookups in ScDocument::GetLookupCache
    
    doing an emplace_hint when the iterator points to end(), doesn't really
    help, so rather attempt to insert a fake value
    
    Change-Id: I44b89858284c6bebaa0e36daf0a4094fe06493c4
    Reviewed-on: https://gerrit.libreoffice.org/72419
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 56506490ec5d..b87d73a8da56 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1136,12 +1136,12 @@ ScLookupCache & ScDocument::GetLookupCache( const ScRange & rRange, ScInterprete
     ScLookupCacheMap*& rpCacheMap = pContext->mScLookupCache;
     if (!rpCacheMap)
         rpCacheMap = new ScLookupCacheMap;
-    auto findIt(rpCacheMap->aCacheMap.find(rRange));
-    if (findIt == rpCacheMap->aCacheMap.end())
+    // insert with temporary value to avoid doing two lookups
+    auto [findIt, bInserted] = rpCacheMap->aCacheMap.emplace(rRange, nullptr);
+    if (bInserted)
     {
-        auto insertIt = rpCacheMap->aCacheMap.emplace_hint(findIt,
-                    rRange, std::make_unique<ScLookupCache>(this, rRange, *rpCacheMap) );
-        pCache = insertIt->second.get();
+        findIt->second = std::make_unique<ScLookupCache>(this, rRange, *rpCacheMap);
+        pCache = findIt->second.get();
         // The StartListeningArea() call is not thread-safe, as all threads
         // would access the same SvtBroadcaster.
         osl::MutexGuard guard( mScLookupMutex );


More information about the Libreoffice-commits mailing list