From 0f0801ac9fc2196b568bd6c4a5fb3f16a928c2d3 Mon Sep 17 00:00:00 2001 From: WeiN76LQh Date: Tue, 26 Nov 2024 18:21:14 +0000 Subject: [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. --- view/sharedcache/core/SharedCache.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'view/sharedcache/core/SharedCache.h') 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> ParseExportTrie( std::shared_ptr linkeditFile, const SharedCacheMachOHeader& header); - std::unordered_map> GetExportListForHeader(SharedCacheMachOHeader header, std::function()> provideLinkeditFile, bool* didModifyExportList = nullptr); + std::shared_ptr>> GetExportListForHeader(SharedCacheMachOHeader header, + std::function()> provideLinkeditFile, bool* didModifyExportList = nullptr); + Ref TypeLibraryForImage(const std::string& installName); -- cgit v1.3.1