From cf46e520356d4a4f73e68be87965b9a8c0bbc109 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Tue, 9 Mar 2021 20:06:28 +0100 Subject: [PATCH] gsdump: simplify a switch case and do-while --- pcsx2/gui/Dialogs/GSDumpDialog.cpp | 45 ++++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index 7d8c67a9a1..02fe6c37b2 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2020 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -727,43 +727,29 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread() while (m_dump_file->Tell() < m_dump_file->Length()) { - GSType id = Transfer; + GSType id; + GSTransferPath id_transfer = Dummy; m_dump_file->Read(&id, 1); + s32 size = 0; switch (id) { case Transfer: - { - GSTransferPath id_transfer; m_dump_file->Read(&id_transfer, 1); - s32 size = 0; m_dump_file->Read(&size, 4); - std::unique_ptr transfer_data(new char[size]); - m_dump_file->Read(transfer_data.get(), size); - m_root_window->m_dump_packets.push_back({id, std::move(transfer_data), size, id_transfer}); break; - } case VSync: - { - std::unique_ptr vsync(new char[1]); - m_dump_file->Read(vsync.get(), 1); - m_root_window->m_dump_packets.push_back({id, std::move(vsync), 1, Dummy}); + size = 1; break; - } case ReadFIFO2: - { - std::unique_ptr fifo(new char[4]); - m_dump_file->Read(fifo.get(), 4); - m_root_window->m_dump_packets.push_back({id, std::move(fifo), 4, Dummy}); + size = 4; break; - } case Registers: - { - std::unique_ptr regs_tmp(new char[8192]); - m_dump_file->Read(regs_tmp.get(), 8192); - m_root_window->m_dump_packets.push_back({id, std::move(regs_tmp), 8192, Dummy}); + size = 8192; break; - } } + std::unique_ptr data(new char[size]); + m_dump_file->Read(data.get(), size); + m_root_window->m_dump_packets.push_back({id, std::move(data), size, id_transfer}); } GetCorePlugins().Init(); @@ -848,15 +834,12 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread() m_root_window->ProcessDumpEvent({VSync, 0, 0, Dummy}, regs); } } - else + else if (m_root_window->m_dump_packets.size()) { - while (i < (m_root_window->m_dump_packets.size())) - { + do m_root_window->ProcessDumpEvent(m_root_window->m_dump_packets[i++], regs); + while (i < m_root_window->m_dump_packets.size() && m_root_window->m_dump_packets[i].id != VSync); - if (i >= m_root_window->m_dump_packets.size() || m_root_window->m_dump_packets[i].id == VSync) - break; - } if (i >= m_root_window->m_dump_packets.size()) i = 0; } @@ -874,4 +857,4 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread() OnStop(); return; -} \ No newline at end of file +}