Skip to content

Commit 8cfc99b

Browse files
[DWARFLinker] Avoid repeated hash lookups (NFC) (#110377)
1 parent 871e32b commit 8cfc99b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class CachedPathResolver {
4242

4343
// If the ParentPath has not yet been resolved, resolve and cache it for
4444
// future look-ups.
45-
if (!ResolvedPaths.count(ParentPath)) {
45+
auto [It, Inserted] = ResolvedPaths.try_emplace(ParentPath);
46+
if (Inserted) {
4647
SmallString<256> RealPath;
4748
sys::fs::real_path(ParentPath, RealPath);
48-
ResolvedPaths.insert(
49-
{ParentPath, std::string(RealPath.c_str(), RealPath.size())});
49+
It->second = std::string(RealPath);
5050
}
5151

5252
// Join the file name again with the resolved path.
53-
SmallString<256> ResolvedPath(ResolvedPaths[ParentPath]);
53+
SmallString<256> ResolvedPath(It->second);
5454
sys::path::append(ResolvedPath, FileName);
5555
return StringPool.internString(ResolvedPath);
5656
}

0 commit comments

Comments
 (0)