Kaydet (Commit) 4c2034b8 authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 0e4c542f
...@@ -1136,12 +1136,12 @@ ScLookupCache & ScDocument::GetLookupCache( const ScRange & rRange, ScInterprete ...@@ -1136,12 +1136,12 @@ ScLookupCache & ScDocument::GetLookupCache( const ScRange & rRange, ScInterprete
ScLookupCacheMap*& rpCacheMap = pContext->mScLookupCache; ScLookupCacheMap*& rpCacheMap = pContext->mScLookupCache;
if (!rpCacheMap) if (!rpCacheMap)
rpCacheMap = new ScLookupCacheMap; rpCacheMap = new ScLookupCacheMap;
auto findIt(rpCacheMap->aCacheMap.find(rRange)); // insert with temporary value to avoid doing two lookups
if (findIt == rpCacheMap->aCacheMap.end()) auto [findIt, bInserted] = rpCacheMap->aCacheMap.emplace(rRange, nullptr);
if (bInserted)
{ {
auto insertIt = rpCacheMap->aCacheMap.emplace_hint(findIt, findIt->second = std::make_unique<ScLookupCache>(this, rRange, *rpCacheMap);
rRange, std::make_unique<ScLookupCache>(this, rRange, *rpCacheMap) ); pCache = findIt->second.get();
pCache = insertIt->second.get();
// The StartListeningArea() call is not thread-safe, as all threads // The StartListeningArea() call is not thread-safe, as all threads
// would access the same SvtBroadcaster. // would access the same SvtBroadcaster.
osl::MutexGuard guard( mScLookupMutex ); osl::MutexGuard guard( mScLookupMutex );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment