From b4136d2834dcdbc5c24dc0444efbfb3fc3b2e45d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 21 Jul 2024 16:15:40 +1000 Subject: [PATCH] TimingEvents: Avoid heap allocation in SortEvents() --- src/core/timing_event.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/timing_event.cpp b/src/core/timing_event.cpp index d490df89b..d31ff01dd 100644 --- a/src/core/timing_event.cpp +++ b/src/core/timing_event.cpp @@ -1,13 +1,17 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "timing_event.h" -#include "common/assert.h" -#include "common/log.h" #include "cpu_core.h" #include "cpu_core_private.h" #include "system.h" + #include "util/state_wrapper.h" + +#include "common/assert.h" +#include "common/log.h" +#include "common/thirdparty/SmallVector.h" + Log_SetChannel(TimingEvents); namespace TimingEvents { @@ -248,7 +252,7 @@ void TimingEvents::RemoveActiveEvent(TimingEvent* event) void TimingEvents::SortEvents() { - std::vector events; + llvm::SmallVector events; events.reserve(s_state.active_event_count); TimingEvent* next = s_state.active_events_head;