mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
PPCSymbolDB: GetDescription by std::string_view
Should save a lot of deep copies.
This commit is contained in:
@ -303,6 +303,7 @@ add_executable(dolphin-emu
|
||||
QtUtils/ElidedButton.h
|
||||
QtUtils/FileOpenEventFilter.cpp
|
||||
QtUtils/FileOpenEventFilter.h
|
||||
QtUtils/FromStdString.h
|
||||
QtUtils/ImageConverter.cpp
|
||||
QtUtils/ImageConverter.h
|
||||
QtUtils/ModalMessageBox.cpp
|
||||
|
@ -193,11 +193,8 @@ void BreakpointWidget::Update()
|
||||
m_table->setItem(i, 0, active);
|
||||
m_table->setItem(i, 1, create_item(QStringLiteral("BP")));
|
||||
|
||||
if (ppc_symbol_db.GetSymbolFromAddr(bp.address))
|
||||
{
|
||||
m_table->setItem(
|
||||
i, 2, create_item(QString::fromStdString(ppc_symbol_db.GetDescription(bp.address))));
|
||||
}
|
||||
if (const Common::Symbol* const symbol = ppc_symbol_db.GetSymbolFromAddr(bp.address))
|
||||
m_table->setItem(i, 2, create_item(QString::fromStdString(symbol->name)));
|
||||
|
||||
m_table->setItem(i, 3,
|
||||
create_item(QStringLiteral("%1").arg(bp.address, 8, 16, QLatin1Char('0'))));
|
||||
@ -234,12 +231,8 @@ void BreakpointWidget::Update()
|
||||
m_table->setItem(i, 0, active);
|
||||
m_table->setItem(i, 1, create_item(QStringLiteral("MBP")));
|
||||
|
||||
if (ppc_symbol_db.GetSymbolFromAddr(mbp.start_address))
|
||||
{
|
||||
m_table->setItem(
|
||||
i, 2,
|
||||
create_item(QString::fromStdString(ppc_symbol_db.GetDescription(mbp.start_address))));
|
||||
}
|
||||
if (const Common::Symbol* const symbol = ppc_symbol_db.GetSymbolFromAddr(mbp.start_address))
|
||||
m_table->setItem(i, 2, create_item(QString::fromStdString(symbol->name)));
|
||||
|
||||
if (mbp.is_ranged)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "DolphinQt/Debugger/AssembleInstructionDialog.h"
|
||||
#include "DolphinQt/Debugger/PatchInstructionDialog.h"
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/QtUtils/FromStdString.h"
|
||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||
#include "DolphinQt/Resources.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
@ -326,7 +327,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
||||
|
||||
std::string ins = (split == std::string::npos ? disas : disas.substr(0, split));
|
||||
std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
|
||||
std::string desc = debug_interface.GetDescription(addr);
|
||||
const std::string_view desc = debug_interface.GetDescription(addr);
|
||||
|
||||
// Adds whitespace and a minimum size to ins and param. Helps to prevent frequent resizing while
|
||||
// scrolling.
|
||||
@ -334,7 +335,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
||||
QStringLiteral("%1").arg(QString::fromStdString(ins), -7, QLatin1Char(' '));
|
||||
const QString param_formatted =
|
||||
QStringLiteral("%1").arg(QString::fromStdString(param), -19, QLatin1Char(' '));
|
||||
const QString desc_formatted = QStringLiteral("%1 ").arg(QString::fromStdString(desc));
|
||||
const QString desc_formatted = QStringLiteral("%1 ").arg(QtUtils::FromStdString(desc));
|
||||
|
||||
auto* ins_item = new QTableWidgetItem(ins_formatted);
|
||||
auto* param_item = new QTableWidgetItem(param_formatted);
|
||||
@ -374,7 +375,7 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
||||
branch.is_link = IsBranchInstructionWithLink(ins);
|
||||
|
||||
description_item->setText(
|
||||
tr("--> %1").arg(QString::fromStdString(debug_interface.GetDescription(branch_addr))));
|
||||
tr("--> %1").arg(QtUtils::FromStdString(debug_interface.GetDescription(branch_addr))));
|
||||
param_item->setForeground(dark_theme ? QColor(255, 135, 255) : Qt::magenta);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/QtUtils/FromStdString.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
ThreadWidget::ThreadWidget(QWidget* parent) : QDockWidget(parent)
|
||||
@ -461,7 +462,7 @@ void ThreadWidget::UpdateThreadCallstack(const Core::CPUThreadGuard& guard,
|
||||
m_callstack_table->setItem(i, 2, new QTableWidgetItem(format_hex(lr_save)));
|
||||
m_callstack_table->setItem(
|
||||
i, 3,
|
||||
new QTableWidgetItem(QString::fromStdString(
|
||||
new QTableWidgetItem(QtUtils::FromStdString(
|
||||
guard.GetSystem().GetPowerPC().GetDebugInterface().GetDescription(lr_save))));
|
||||
}
|
||||
else
|
||||
|
@ -396,6 +396,7 @@
|
||||
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
|
||||
<QtMoc Include="QtUtils\ElidedButton.h" />
|
||||
<QtMoc Include="QtUtils\FileOpenEventFilter.h" />
|
||||
<ClInclude Include="QtUtils\FromStdString.h" />
|
||||
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
|
||||
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
|
||||
<ClInclude Include="QtUtils\SetWindowDecorations.h" />
|
||||
|
23
Source/Core/DolphinQt/QtUtils/FromStdString.h
Normal file
23
Source/Core/DolphinQt/QtUtils/FromStdString.h
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <string_view>
|
||||
|
||||
namespace QtUtils
|
||||
{
|
||||
inline QString FromStdString(std::string_view s)
|
||||
{
|
||||
return QString::fromUtf8(s.data(), s.size());
|
||||
}
|
||||
inline QString FromStdString(std::u8string_view s)
|
||||
{
|
||||
return QString::fromUtf8(s.data(), s.size());
|
||||
}
|
||||
inline QString FromStdString(std::u16string_view s)
|
||||
{
|
||||
return QString::fromUtf16(s.data(), s.size());
|
||||
}
|
||||
} // namespace QtUtils
|
Reference in New Issue
Block a user