1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Merge pull request #23321 from ZehMatt/window-alloc

Eliminate copying the window list each update
This commit is contained in:
Matt
2024-12-04 21:40:33 +02:00
committed by GitHub
2 changed files with 3 additions and 10 deletions

View File

@@ -94,8 +94,7 @@ std::list<std::shared_ptr<WindowBase>>::iterator WindowGetIterator(const WindowB
void WindowVisitEach(std::function<void(WindowBase*)> func)
{
auto windowList = g_window_list;
for (auto& w : windowList)
for (auto& w : g_window_list)
{
if (w->flags & WF_DEAD)
continue;
@@ -142,7 +141,8 @@ void WindowUpdateAllViewports()
*/
void WindowUpdateAll()
{
WindowFlushDead();
// Remove all windows in g_window_list that have the WF_DEAD flag
g_window_list.remove_if([](auto&& w) -> bool { return w->flags & WF_DEAD; });
// Periodic update happens every second so 40 ticks.
if (gCurrentRealTimeTicks >= gWindowUpdateTicks)
@@ -238,12 +238,6 @@ void WindowClose(WindowBase& w)
w.flags |= WF_DEAD;
}
void WindowFlushDead()
{
// Remove all windows in g_window_list that have the WF_DEAD flag
g_window_list.remove_if([](auto&& w) -> bool { return w->flags & WF_DEAD; });
}
template<typename TPred>
static void WindowCloseByCondition(TPred pred, uint32_t flags = WindowCloseFlags::None)
{

View File

@@ -475,7 +475,6 @@ WindowBase* WindowBringToFrontByClassWithFlags(WindowClass cls, uint16_t flags);
WindowBase* WindowBringToFrontByNumber(WindowClass cls, rct_windownumber number);
void WindowClose(WindowBase& window);
void WindowFlushDead();
void WindowCloseByClass(WindowClass cls);
void WindowCloseByNumber(WindowClass cls, rct_windownumber number);
void WindowCloseByNumber(WindowClass cls, EntityId number);