From 9b77a9aff7360ecefb58309f0bdba9c106ee1542 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 20 Jul 2024 13:41:50 +1000 Subject: [PATCH] TimingEvents: Move interrupt dispatch to end of loop Saves another iteration. --- src/core/timing_event.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/timing_event.cpp b/src/core/timing_event.cpp index 542dea66c..c7cea2df3 100644 --- a/src/core/timing_event.cpp +++ b/src/core/timing_event.cpp @@ -16,7 +16,7 @@ static void SortEvent(TimingEvent* event); static void AddActiveEvent(TimingEvent* event); static void RemoveActiveEvent(TimingEvent* event); static void SortEvents(); -static TimingEvent* FindActiveEvent(const char* name); +static TimingEvent* FindActiveEvent(const std::string_view name); namespace { struct TimingEventsState @@ -268,11 +268,11 @@ void TimingEvents::SortEvents() AddActiveEvent(event); } -static TimingEvent* TimingEvents::FindActiveEvent(const char* name) +static TimingEvent* TimingEvents::FindActiveEvent(const std::string_view name) { for (TimingEvent* event = s_state.active_events_head; event; event = event->next) { - if (event->GetName().compare(name) == 0) + if (event->GetName() == name) return event; } @@ -296,9 +296,6 @@ void TimingEvents::RunEvents() do { - if (CPU::HasPendingInterrupt()) - CPU::DispatchInterrupt(); - TickCount pending_ticks = CPU::GetPendingTicks(); if (pending_ticks >= s_state.active_events_head->GetDowncount()) { @@ -348,6 +345,9 @@ void TimingEvents::RunEvents() System::FrameDone(); } + if (CPU::HasPendingInterrupt()) + CPU::DispatchInterrupt(); + UpdateCPUDowncount(); } while (CPU::GetPendingTicks() >= CPU::g_state.downcount); } @@ -375,7 +375,7 @@ bool TimingEvents::DoState(StateWrapper& sw) if (sw.HasError()) return false; - TimingEvent* event = FindActiveEvent(event_name.c_str()); + TimingEvent* event = FindActiveEvent(event_name); if (!event) { WARNING_LOG("Save state has event '{}', but couldn't find this event when loading.", event_name);