summaryrefslogtreecommitdiff
path: root/view/sharedcache/core
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-07-09 18:20:47 -0700
committerMark Rowe <mark@vector35.com>2025-07-10 16:13:22 -0700
commita2ccfa22aa3f04484cba5dd8e58aeda51d518287 (patch)
treebb800fccf3da77be1fd88627c74eac0cb6d6a3e6 /view/sharedcache/core
parentebac408aec4bbeab7db3d6336520f5ea2a033a2c (diff)
[DSC] Fix GetRegionAt / optimize GetRegionContaining
`GetRegionAt` was really providing the semantics of `GetRegionContaining` due to `m_regions` being an `AddressRangeMap` and using transparent comparators to allow `find` to work with any address in the range. `GetRegionAt` is updated to verify that the start address of the region that was found matches the requested address. `GetRegionContaining` is updated to use `AddressRangeMap::find` rather than doing a linear search over all regions.
Diffstat (limited to 'view/sharedcache/core')
-rw-r--r--view/sharedcache/core/SharedCache.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp
index 0198ac48..c36c9ede 100644
--- a/view/sharedcache/core/SharedCache.cpp
+++ b/view/sharedcache/core/SharedCache.cpp
@@ -488,17 +488,17 @@ std::optional<CacheEntry> SharedCache::GetEntryWithImage(const CacheImage& image
std::optional<CacheRegion> SharedCache::GetRegionAt(const uint64_t address) const
{
const auto it = m_regions.find(address);
- if (it == m_regions.end())
+ if (it == m_regions.end() || it->second.start != address)
return std::nullopt;
return it->second;
}
std::optional<CacheRegion> SharedCache::GetRegionContaining(const uint64_t address) const
{
- for (const auto& [range, region] : m_regions)
- if (address >= range.start && address < range.end)
- return region;
- return std::nullopt;
+ const auto it = m_regions.find(address);
+ if (it == m_regions.end())
+ return std::nullopt;
+ return it->second;
}
std::optional<CacheImage> SharedCache::GetImageAt(const uint64_t address) const