diff options
author | Lioncash <mathew1800@gmail.com> | 2020-08-06 09:11:19 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-08-06 09:11:21 +0200 |
commit | 61cd7eb47d947bd332ea306e74a1491c42854a61 (patch) | |
tree | 774cd9eedd36f1510d45575bc1b97926b97a594f | |
parent | freezer: Take address values by value (diff) | |
download | yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar.gz yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar.bz2 yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar.lz yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar.xz yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.tar.zst yuzu-61cd7eb47d947bd332ea306e74a1491c42854a61.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/tools/freezer.cpp | 26 | ||||
-rw-r--r-- | src/core/tools/freezer.h | 7 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp index 4ca1870f2..5c674a099 100644 --- a/src/core/tools/freezer.cpp +++ b/src/core/tools/freezer.cpp @@ -113,19 +113,15 @@ void Freezer::Unfreeze(VAddr address) { bool Freezer::IsFrozen(VAddr address) const { std::lock_guard lock{entries_mutex}; - return std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { - return entry.address == address; - }) != entries.end(); + return FindEntry(address) != entries.cend(); } void Freezer::SetFrozenValue(VAddr address, u64 value) { std::lock_guard lock{entries_mutex}; - const auto iter = std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { - return entry.address == address; - }); + const auto iter = FindEntry(address); - if (iter == entries.end()) { + if (iter == entries.cend()) { LOG_ERROR(Common_Memory, "Tried to set freeze value for address={:016X} that is not frozen!", address); return; @@ -140,11 +136,9 @@ void Freezer::SetFrozenValue(VAddr address, u64 value) { std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const { std::lock_guard lock{entries_mutex}; - const auto iter = std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { - return entry.address == address; - }); + const auto iter = FindEntry(address); - if (iter == entries.end()) { + if (iter == entries.cend()) { return std::nullopt; } @@ -157,6 +151,16 @@ std::vector<Freezer::Entry> Freezer::GetEntries() const { return entries; } +Freezer::Entries::iterator Freezer::FindEntry(VAddr address) { + return std::find_if(entries.begin(), entries.end(), + [address](const Entry& entry) { return entry.address == address; }); +} + +Freezer::Entries::const_iterator Freezer::FindEntry(VAddr address) const { + return std::find_if(entries.begin(), entries.end(), + [address](const Entry& entry) { return entry.address == address; }); +} + void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) { if (!IsActive()) { LOG_DEBUG(Common_Memory, "Memory freezer has been deactivated, ending callback events."); diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h index 2b2326bc4..0fdb701a7 100644 --- a/src/core/tools/freezer.h +++ b/src/core/tools/freezer.h @@ -73,13 +73,18 @@ public: std::vector<Entry> GetEntries() const; private: + using Entries = std::vector<Entry>; + + Entries::iterator FindEntry(VAddr address); + Entries::const_iterator FindEntry(VAddr address) const; + void FrameCallback(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); void FillEntryReads(); std::atomic_bool active{false}; mutable std::mutex entries_mutex; - std::vector<Entry> entries; + Entries entries; std::shared_ptr<Core::Timing::EventType> event; Core::Timing::CoreTiming& core_timing; |