!10291 fix the time taken when generate root edge

Merge pull request !10291 from yangxiaoshuai2022/rawheapdump
This commit is contained in:
openharmony_ci 2024-11-22 00:28:05 +00:00 committed by Gitee
commit fa24ae78ef
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 4 additions and 12 deletions

View File

@ -228,6 +228,7 @@ bool RawHeapTranslate::ReadRootTable(std::ifstream &file, uint32_t offset, uint3
EdgeType type = EdgeType::SHORTCUT;
char *addr = roots.data();
std::vector<std::shared_ptr<Edge>> rootEdges;
for (uint32_t i = 0; i < rootNum; i++) {
uint64_t rootAddr = ByteToU64(addr);
addr += sizeof(uint64_t);
@ -236,10 +237,11 @@ bool RawHeapTranslate::ReadRootTable(std::ifstream &file, uint32_t offset, uint3
continue;
}
auto edge = std::make_shared<Edge>(Edge(type, syntheticRoot, rootNode->second, edgeStrId));
edges_.insert(edges_.begin(), edge);
rootEdges.emplace_back(edge);
syntheticRoot->edgeCount++;
}
edges_.insert(edges_.begin(), rootEdges.begin(), rootEdges.end());
LOG_INFO("RawHeapTranslate::ReadRootTable: find root obj " + std::to_string(rootNum));
return true;
}

View File

@ -22,16 +22,7 @@ std::string StringHashMap::GetStringByKey(StringKey key) const
if (it != hashmap_.end()) {
return it->second;
}
return nullptr;
}
std::pair<uint64_t, std::string> StringHashMap::GetStringAndIdPair(StringKey key) const
{
auto it = hashmap_.find(key);
if (it != hashmap_.end()) {
return {indexMap_.at(key), it->second};
}
return {1, nullptr}; // 1 : invalid id
return "";
}
StringId StringHashMap::InsertStrAndGetStringId(const std::string &str)

View File

@ -45,7 +45,6 @@ public:
* Get string by its hash key
*/
std::string GetStringByKey(StringKey key) const;
std::pair<uint64_t, std::string> GetStringAndIdPair(StringKey key) const;
StringId InsertStrAndGetStringId(const std::string &cstrArg);
size_t GetCapcity() const
{