From da7bab98907a700d1e525ccafe8f623d0927a724 Mon Sep 17 00:00:00 2001 From: Oxore Date: Wed, 22 May 2024 23:44:38 +0300 Subject: Optimize compile times by removing find_if usage --- bus.cpp | 57 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'bus.cpp') diff --git a/bus.cpp b/bus.cpp index f9aab5f..ac18208 100644 --- a/bus.cpp +++ b/bus.cpp @@ -7,7 +7,6 @@ #include "vdp.hpp" #include "io.hpp" -#include #include #include #include @@ -115,21 +114,21 @@ static inline bool ranges_overlap( static inline void m68k_read_callback(const uint32_t address, const uint32_t size) { - const auto access_it = std::find_if( - access_bkpts.begin(), - access_bkpts.end(), - [&](const Breakpoint& b) { return ranges_overlap(address, size, b.offset, b.length); }); - if (access_it != access_bkpts.end()) { - printf("Access watchpoint @ 0x%08x\n", address); - m68k_breakpoint_callback(); + for (size_t bi = 0; bi < access_bkpts.size(); bi++) { + const auto& b = access_bkpts[bi]; + if (ranges_overlap(address, size, b.offset, b.length)) { + printf("Access watchpoint @ 0x%08x\n", address); + m68k_breakpoint_callback(); + break; + } } - const auto it = std::find_if( - read_bkpts.begin(), - read_bkpts.end(), - [&](const Breakpoint& b) { return ranges_overlap(address, size, b.offset, b.length); }); - if (it != read_bkpts.end()) { - printf("Read watchpoint @ 0x%08x\n", address); - m68k_breakpoint_callback(); + for (size_t bi = 0; bi < read_bkpts.size(); bi++) { + const auto& b = read_bkpts[bi]; + if (ranges_overlap(address, size, b.offset, b.length)) { + printf("Read watchpoint @ 0x%08x\n", address); + m68k_breakpoint_callback(); + break; + } } } @@ -196,21 +195,21 @@ static inline void memory_write_concrete( static inline void m68k_write_callback(const uint32_t address, const uint32_t size) { - const auto access_it = std::find_if( - access_bkpts.begin(), - access_bkpts.end(), - [&](const Breakpoint& b) { return ranges_overlap(address, size, b.offset, b.length); }); - if (access_it != access_bkpts.end()) { - printf("Access watchpoint @ 0x%08x\n", address); - m68k_breakpoint_callback(); + for (size_t bi = 0; bi < access_bkpts.size(); bi++) { + const auto& b = access_bkpts[bi]; + if (ranges_overlap(address, size, b.offset, b.length)) { + printf("Access watchpoint @ 0x%08x\n", address); + m68k_breakpoint_callback(); + break; + } } - const auto it = std::find_if( - write_bkpts.begin(), - write_bkpts.end(), - [&](const Breakpoint& b) { return ranges_overlap(address, size, b.offset, b.length); }); - if (it != write_bkpts.end()) { - printf("Write watchpoint @ 0x%08x\n", address); - m68k_breakpoint_callback(); + for (size_t bi = 0; bi < read_bkpts.size(); bi++) { + const auto& b = read_bkpts[bi]; + if (ranges_overlap(address, size, b.offset, b.length)) { + printf("Write watchpoint @ 0x%08x\n", address); + m68k_breakpoint_callback(); + break; + } } } -- cgit v1.2.3