40 lines
1.5 KiB
Diff
40 lines
1.5 KiB
Diff
# UNDF: UNDF-2026-000001065
|
|
# UNDF: UNDF-2026-XXXXXXXXX
|
|
--- a/src/z80.cpp
|
|
+++ b/src/z80.cpp
|
|
@@ -160,6 +160,7 @@ static void* const ed_jumpTable[256] = {
|
|
#include <vector>
|
|
#include <algorithm>
|
|
+#include <unordered_set>
|
|
|
|
t_z80regs z80;
|
|
std::vector<Breakpoint> breakpoints;
|
|
+// Fast O(1) address lookup set kept in sync with breakpoints vector.
|
|
+std::unordered_set<dword> breakpoint_addresses;
|
|
std::vector<Watchpoint> watchpoints;
|
|
@@ -164,16 +165,24 @@ std::vector<Watchpoint> watchpoints;
|
|
// All callers that mutate breakpoints must also mutate breakpoint_addresses.
|
|
// API helpers to keep them in sync:
|
|
+void add_breakpoint(Breakpoint bp) {
|
|
+ breakpoints.push_back(bp);
|
|
+ breakpoint_addresses.insert(bp.address);
|
|
+}
|
|
+
|
|
+void remove_breakpoint(std::size_t idx) {
|
|
+ breakpoint_addresses.erase(breakpoints[idx].address);
|
|
+ breakpoints.erase(breakpoints.begin() + idx);
|
|
+}
|
|
+
|
|
+void remove_breakpoints_if(std::function<bool(const Breakpoint&)> pred) {
|
|
+ for (const auto& bp : breakpoints) {
|
|
+ if (pred(bp)) breakpoint_addresses.erase(bp.address);
|
|
+ }
|
|
+ breakpoints.erase(std::remove_if(breakpoints.begin(), breakpoints.end(), pred), breakpoints.end());
|
|
+}
|
|
--- a/src/z80.cpp
|
|
+++ b/src/z80.cpp
|
|
@@ -1098,7 +1098,7 @@ dword z80_execute(dword iCycleCountInit)
|
|
if (!breakpoints.empty()) {
|
|
- if ((z80.breakpoint_reached = std::any_of(breakpoints.begin(), breakpoints.end(), [&](const auto& b) { return b.address == _PC; }))) break;
|
|
+ if ((z80.breakpoint_reached = (breakpoint_addresses.count(_PC) != 0))) break;
|
|
}
|