Common: Drop String, add SmallString

This commit is contained in:
Stenzek
2023-09-20 23:49:14 +10:00
parent 3c68543491
commit ac0601f408
55 changed files with 1500 additions and 2062 deletions

View File

@ -2,9 +2,13 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "debuggermodels.h"
#include "core/cpu_core.h"
#include "core/cpu_core_private.h"
#include "core/cpu_disasm.h"
#include "common/small_string.h"
#include <QtGui/QColor>
#include <QtGui/QIcon>
#include <QtGui/QPalette>
@ -21,7 +25,9 @@ DebuggerCodeModel::DebuggerCodeModel(QObject* parent /*= nullptr*/) : QAbstractT
m_breakpoint_pixmap = QIcon(QStringLiteral(":/icons/media-record.png")).pixmap(QSize(12, 12));
}
DebuggerCodeModel::~DebuggerCodeModel() {}
DebuggerCodeModel::~DebuggerCodeModel()
{
}
int DebuggerCodeModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const
{
@ -92,7 +98,7 @@ QVariant DebuggerCodeModel::data(const QModelIndex& index, int role /*= Qt::Disp
SmallString str;
CPU::DisassembleInstruction(&str, address, instruction_bits);
return QString::fromUtf8(str.GetCharArray(), static_cast<int>(str.GetLength()));
return QString::fromUtf8(str.c_str(), static_cast<int>(str.length()));
}
case 4:
@ -107,7 +113,7 @@ QVariant DebuggerCodeModel::data(const QModelIndex& index, int role /*= Qt::Disp
TinyString str;
CPU::DisassembleInstructionComment(&str, address, instruction_bits, &CPU::g_state.regs);
return QString::fromUtf8(str.GetCharArray(), static_cast<int>(str.GetLength()));
return QString::fromUtf8(str.c_str(), static_cast<int>(str.length()));
}
default:
@ -287,9 +293,13 @@ void DebuggerCodeModel::setBreakpointState(VirtualMemoryAddress address, bool en
}
}
DebuggerRegistersModel::DebuggerRegistersModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent) {}
DebuggerRegistersModel::DebuggerRegistersModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent)
{
}
DebuggerRegistersModel::~DebuggerRegistersModel() {}
DebuggerRegistersModel::~DebuggerRegistersModel()
{
}
int DebuggerRegistersModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const
{
@ -314,8 +324,8 @@ QVariant DebuggerRegistersModel::data(const QModelIndex& index, int role /*= Qt:
{
case 0: // address
{
if (role == Qt::DisplayRole)
return QString::fromUtf8(CPU::g_debugger_register_list[reg_index].name);
if (role == Qt::DisplayRole)
return QString::fromUtf8(CPU::g_debugger_register_list[reg_index].name);
}
break;
@ -372,9 +382,13 @@ void DebuggerRegistersModel::saveCurrentValues()
m_old_reg_values[i] = CPU::g_state.regs.r[i];
}
DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent) {}
DebuggerStackModel::DebuggerStackModel(QObject* parent /*= nullptr*/) : QAbstractListModel(parent)
{
}
DebuggerStackModel::~DebuggerStackModel() {}
DebuggerStackModel::~DebuggerStackModel()
{
}
int DebuggerStackModel::rowCount(const QModelIndex& parent /*= QModelIndex()*/) const
{