Core/PowerPC: Return AvailableCPUCores() as a std::span.

This commit is contained in:
Admiral H. Curtiss 2023-08-16 19:15:22 +02:00
parent 51f807b63a
commit a34f221782
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
3 changed files with 10 additions and 7 deletions

View File

@ -236,9 +236,9 @@ void PowerPCManager::InitializeCPUCore(CPUCore cpu_core)
m_mode = m_cpu_core_base == &interpreter ? CoreMode::Interpreter : CoreMode::JIT;
}
const std::vector<CPUCore>& AvailableCPUCores()
std::span<const CPUCore> AvailableCPUCores()
{
static const std::vector<CPUCore> cpu_cores = {
static constexpr auto cpu_cores = {
#ifdef _M_X86_64
CPUCore::JIT64,
#elif defined(_M_ARM_64)

View File

@ -6,6 +6,7 @@
#include <array>
#include <cstddef>
#include <iosfwd>
#include <span>
#include <tuple>
#include <type_traits>
#include <vector>
@ -238,7 +239,7 @@ static_assert(offsetof(PowerPC::PowerPCState, above_fits_in_first_0x100) <= 0x10
#endif
#endif
const std::vector<CPUCore>& AvailableCPUCores();
std::span<const CPUCore> AvailableCPUCores();
CPUCore DefaultCPUCore();
class PowerPCManager

View File

@ -190,9 +190,11 @@ void AdvancedPane::CreateLayout()
void AdvancedPane::ConnectLayout()
{
connect(m_cpu_emulation_engine_combobox,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [](int index) {
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]);
connect(m_cpu_emulation_engine_combobox, qOverload<int>(&QComboBox::currentIndexChanged),
[](int index) {
const auto cpu_cores = PowerPC::AvailableCPUCores();
if (index >= 0 && static_cast<size_t>(index) < cpu_cores.size())
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, cpu_cores[index]);
});
connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, [this](bool enable_clock_override) {
@ -243,7 +245,7 @@ void AdvancedPane::Update()
const bool enable_ram_override_widgets = Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE);
const bool enable_custom_rtc_widgets = Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE) && !running;
const std::vector<PowerPC::CPUCore>& available_cpu_cores = PowerPC::AvailableCPUCores();
const auto available_cpu_cores = PowerPC::AvailableCPUCores();
const auto cpu_core = Config::Get(Config::MAIN_CPU_CORE);
for (size_t i = 0; i < available_cpu_cores.size(); ++i)
{