From 28aef35c76c4b6c9215aeb82f974032031154bd1 Mon Sep 17 00:00:00 2001 From: WeiN76LQh Date: Tue, 26 Nov 2024 16:15:58 +0000 Subject: [SharedCache] Improve the types for `m_exportInfos` This commit changes 2 things; 1. `m_exportInfos` is now a map where its values are also a map rather than a vector of pairs. The reason for this is that `SharedCache::FindSymbolAtAddrAndApplyToAddr` is a hot path which does by far the most accesses to `m_exportInfos`. In that function it must find the correct symbol for a given address so a map lookup will be much quicker than iterating a vector. The other use cases of `m_exportInfos` would prefer a vector but they are executed very infrequently. 2. The symbols are stored in `m_exportInfos` as references to the `Symbol` type. This makes more sense because otherwise there is a lot of time spent converting to and from a `Symbol` type and a pair of `BNSymbolType` + a `std::string`. --- view/sharedcache/core/SharedCache.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'view/sharedcache/core/SharedCache.h') diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index bb1181b6..fd976ed7 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -567,6 +567,7 @@ namespace SharedCacheCore { struct ViewSpecificState; + private: Ref m_logger; /* VIEW STATE BEGIN -- SERIALIZE ALL OF THIS AND STORE IT IN RAW VIEW */ @@ -641,10 +642,7 @@ 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::vector>> GetExportListForHeader( - SharedCacheMachOHeader header, std::function()> provideLinkeditFile, - bool* didModifyExportList = nullptr); + std::unordered_map> GetExportListForHeader(SharedCacheMachOHeader header, std::function()> provideLinkeditFile, bool* didModifyExportList = nullptr); Ref TypeLibraryForImage(const std::string& installName); -- cgit v1.3.1