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

@@ -147,7 +147,7 @@ void AutoUpdaterDialog::queueGetLatestRelease()
connect(m_network_access_mgr, &QNetworkAccessManager::finished, this, &AutoUpdaterDialog::getLatestReleaseComplete);
SmallString url_string;
url_string.Format(LATEST_RELEASE_URL, getCurrentUpdateTag().c_str());
url_string.format(LATEST_RELEASE_URL, getCurrentUpdateTag().c_str());
QUrl url(QUrl::fromEncoded(QByteArray(url_string)));
QNetworkRequest request(url);

View File

@@ -402,11 +402,11 @@ QString ControllerMacroEditWidget::getSummary() const
SmallString str;
for (const Controller::ControllerBindingInfo* bi : m_binds)
{
if (!str.IsEmpty())
str.AppendCharacter('/');
str.AppendString(bi->name);
if (!str.empty())
str.append('/');
str.append(bi->name);
}
return str.IsEmpty() ? tr("Not Configured") : QString::fromUtf8(str.GetCharArray(), str.GetLength());
return str.empty() ? tr("Not Configured") : QString::fromUtf8(str.c_str(), static_cast<int>(str.length()));
}
void ControllerMacroEditWidget::onSetFrequencyClicked()

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
{

View File

@@ -481,7 +481,7 @@ void GameListWidget::resizeTableViewColumnsToFit()
static TinyString getColumnVisibilitySettingsKeyName(int column)
{
return TinyString::FromFormat("Show%s", GameListModel::getColumnName(static_cast<GameListModel::Column>(column)));
return TinyString::from_fmt("Show{}", GameListModel::getColumnName(static_cast<GameListModel::Column>(column)));
}
void GameListWidget::loadTableViewColumnVisibilitySettings()

View File

@@ -2,7 +2,7 @@
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "memorycardsettingswidget.h"
#include "common/string_util.h"
#include "core/controller.h"
#include "core/settings.h"
#include "inputbindingwidgets.h"
@@ -11,6 +11,10 @@
#include "qtutils.h"
#include "settingsdialog.h"
#include "settingwidgetbinder.h"
#include "common/small_string.h"
#include "common/string_util.h"
#include <QtCore/QUrl>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QLabel>
@@ -168,7 +172,7 @@ void MemoryCardSettingsWidget::onBrowseMemoryCardPathClicked(int index)
void MemoryCardSettingsWidget::onMemoryCardPathChanged(int index)
{
const auto key = TinyString::FromFormat("Card%dPath", index + 1);
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
std::string relative_path(
Path::MakeRelative(m_port_ui[index].memory_card_path->text().toStdString(), EmuFolders::MemoryCards));
m_dialog->setStringSettingValue("MemoryCards", key, relative_path.c_str());
@@ -176,7 +180,7 @@ void MemoryCardSettingsWidget::onMemoryCardPathChanged(int index)
void MemoryCardSettingsWidget::onResetMemoryCardPathClicked(int index)
{
const auto key = TinyString::FromFormat("Card%dPath", index + 1);
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
if (m_dialog->isPerGameSettings())
m_dialog->removeSettingValue("MemoryCards", key);
else
@@ -187,7 +191,7 @@ void MemoryCardSettingsWidget::onResetMemoryCardPathClicked(int index)
void MemoryCardSettingsWidget::updateMemoryCardPath(int index)
{
const auto key = TinyString::FromFormat("Card%dPath", index + 1);
const auto key = TinyString::from_fmt("Card{}Path", index + 1);
std::string path(
m_dialog->getEffectiveStringValue("MemoryCards", key, Settings::GetDefaultSharedMemoryCardName(index).c_str()));
if (!Path::IsAbsolute(path))

View File

@@ -3,6 +3,7 @@
#pragma once
#include "core/types.h"
#include <QtWidgets/QComboBox>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QLineEdit>