summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.h
diff options
context:
space:
mode:
authorWeiN76LQh <WeiN76LQh@github.com>2024-11-26 18:21:14 +0000
committerkat <kat@vector35.com>2025-02-10 10:33:20 -0500
commit0f0801ac9fc2196b568bd6c4a5fb3f16a928c2d3 (patch)
treec68bb505be3aaa6df16862ec89cd8775f5c8b3b0 /view/sharedcache/core/SharedCache.h
parent876a5e2f8eeea13dd4aed5bbf7abc853727dcc85 (diff)
[SharedCache] Make `m_exportInfos` map's values a `shared_ptr`
This avoids expensive copying when returning a value from the map in `SharedCache::GetExportListForHeader`. Additionally it ensures that the value stays alive and at the same location in memory if `m_exportInfos` is modified and requires its storage to be re-allocated. I was unable to use a `unique_ptr` instead of a `shared_ptr` because of copy semantics with `m_exportInfos` in `ViewStateCacheStore`. I don't see things being any worse using `shared_ptr` instead of `unique_ptr` anyway and it means less code changes.
Diffstat (limited to 'view/sharedcache/core/SharedCache.h')
-rw-r--r--view/sharedcache/core/SharedCache.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h
index fd976ed7..2f6f2ae4 100644
--- a/view/sharedcache/core/SharedCache.h
+++ b/view/sharedcache/core/SharedCache.h
@@ -642,7 +642,9 @@ private:
const uint8_t *end, const uint8_t* current, uint64_t textBase, const std::string& currentText);
std::vector<Ref<Symbol>> ParseExportTrie(
std::shared_ptr<MMappedFileAccessor> linkeditFile, const SharedCacheMachOHeader& header);
- std::unordered_map<uint64_t, Ref<Symbol>> GetExportListForHeader(SharedCacheMachOHeader header, std::function<std::shared_ptr<MMappedFileAccessor>()> provideLinkeditFile, bool* didModifyExportList = nullptr);
+ std::shared_ptr<std::unordered_map<uint64_t, Ref<Symbol>>> GetExportListForHeader(SharedCacheMachOHeader header,
+ std::function<std::shared_ptr<MMappedFileAccessor>()> provideLinkeditFile, bool* didModifyExportList = nullptr);
+
Ref<TypeLibrary> TypeLibraryForImage(const std::string& installName);