mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
DolphinQt: Replace QStringLiteral with alternatives where applicable
QStringLiterals generate a buffer so that during runtime there's very
little cost to constructing a QString. However, this also means that
duplicated strings cannot be optimized out into a single entry that gets
referenced everywhere, taking up space in the binary.
Rather than use QStringLiteral(""), we can just use QString{} (the
default constructor) to signify the empty string. This gets rid of an
unnecessary string buffer from being created, saving a tiny bit of
space.
While we're at it, we can just use the character overloads of particular
functions when they're available instead of using a QString overload.
The characters in this case are Latin-1 to begin with, so we can just
specify the characters as QLatin1Char instances to use those overloads.
These will automatically convert to QChar if needed, so this is safe.
This commit is contained in:
@@ -625,8 +625,7 @@ static QString GetResultString(const Result& result)
|
||||
case DataType::String:
|
||||
return QObject::tr("String Match");
|
||||
default:
|
||||
// Make MSVC happy
|
||||
return QStringLiteral("");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,7 +721,7 @@ void CheatsManager::Reset()
|
||||
m_match_table->clear();
|
||||
m_watch_table->clear();
|
||||
m_match_decimal->setChecked(true);
|
||||
m_result_label->setText(QStringLiteral(""));
|
||||
m_result_label->clear();
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ void ARCodeWidget::UpdateList()
|
||||
{
|
||||
const auto& ar = m_ar_codes[i];
|
||||
auto* item = new QListWidgetItem(QString::fromStdString(ar.name)
|
||||
.replace(QStringLiteral("<"), QStringLiteral("<"))
|
||||
.replace(QStringLiteral(">"), QStringLiteral(">")));
|
||||
.replace(QStringLiteral("<"), QChar::fromLatin1('<'))
|
||||
.replace(QStringLiteral(">"), QChar::fromLatin1('>')));
|
||||
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable |
|
||||
Qt::ItemIsDragEnabled);
|
||||
|
||||
@@ -124,7 +124,7 @@ bool CheatCodeEditor::AcceptAR()
|
||||
std::vector<ActionReplay::AREntry> entries;
|
||||
std::vector<std::string> encrypted_lines;
|
||||
|
||||
QStringList lines = m_code_edit->toPlainText().split(QStringLiteral("\n"));
|
||||
QStringList lines = m_code_edit->toPlainText().split(QLatin1Char{'\n'});
|
||||
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ bool CheatCodeEditor::AcceptAR()
|
||||
if (line.isEmpty())
|
||||
continue;
|
||||
|
||||
QStringList values = line.split(QStringLiteral(" "));
|
||||
QStringList values = line.split(QLatin1Char{' '});
|
||||
|
||||
bool good = true;
|
||||
|
||||
@@ -152,7 +152,7 @@ bool CheatCodeEditor::AcceptAR()
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList blocks = line.split(QStringLiteral("-"));
|
||||
QStringList blocks = line.split(QLatin1Char{'-'});
|
||||
|
||||
if (blocks.size() == 3 && blocks[0].size() == 4 && blocks[1].size() == 4 &&
|
||||
blocks[2].size() == 5)
|
||||
@@ -230,7 +230,7 @@ bool CheatCodeEditor::AcceptGecko()
|
||||
{
|
||||
std::vector<Gecko::GeckoCode::Code> entries;
|
||||
|
||||
QStringList lines = m_code_edit->toPlainText().split(QStringLiteral("\n"));
|
||||
QStringList lines = m_code_edit->toPlainText().split(QLatin1Char{'\n'});
|
||||
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
{
|
||||
@@ -239,7 +239,7 @@ bool CheatCodeEditor::AcceptGecko()
|
||||
if (line.isEmpty())
|
||||
continue;
|
||||
|
||||
QStringList values = line.split(QStringLiteral(" "));
|
||||
QStringList values = line.split(QLatin1Char{' '});
|
||||
|
||||
bool good = values.size() == 2;
|
||||
|
||||
@@ -289,7 +289,7 @@ bool CheatCodeEditor::AcceptGecko()
|
||||
m_gecko_code->user_defined = true;
|
||||
|
||||
std::vector<std::string> note_lines;
|
||||
for (QString line : m_notes_edit->toPlainText().split(QStringLiteral("\n")))
|
||||
for (const QString& line : m_notes_edit->toPlainText().split(QLatin1Char{'\n'}))
|
||||
note_lines.push_back(line.toStdString());
|
||||
|
||||
m_gecko_code->notes = std::move(note_lines);
|
||||
|
||||
@@ -263,7 +263,7 @@ DiscIO::Partition FilesystemWidget::GetPartitionFromID(int id)
|
||||
|
||||
void FilesystemWidget::ExtractPartition(const DiscIO::Partition& partition, const QString& out)
|
||||
{
|
||||
ExtractDirectory(partition, QStringLiteral(""), out + QStringLiteral("/files"));
|
||||
ExtractDirectory(partition, QString{}, out + QStringLiteral("/files"));
|
||||
ExtractSystemData(partition, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ void GameConfigEdit::SetOption(const QString& section, const QString& key, const
|
||||
if (value_cursor.isNull())
|
||||
{
|
||||
section_cursor.clearSelection();
|
||||
section_cursor.insertText(QStringLiteral("\n") + new_line);
|
||||
section_cursor.insertText(QLatin1Char{'\n'} + new_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -280,8 +280,8 @@ void GeckoCodeWidget::UpdateList()
|
||||
const auto& code = m_gecko_codes[i];
|
||||
|
||||
auto* item = new QListWidgetItem(QString::fromStdString(code.name)
|
||||
.replace(QStringLiteral("<"), QStringLiteral("<"))
|
||||
.replace(QStringLiteral(">"), QStringLiteral(">")));
|
||||
.replace(QStringLiteral("<"), QChar::fromLatin1('<'))
|
||||
.replace(QStringLiteral(">"), QChar::fromLatin1('>')));
|
||||
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable |
|
||||
Qt::ItemIsDragEnabled);
|
||||
|
||||
@@ -189,7 +189,7 @@ void EnhancementsWidget::LoadPPShaders()
|
||||
m_pp_effect->setEnabled(supports_postprocessing);
|
||||
|
||||
m_pp_effect->setToolTip(supports_postprocessing ?
|
||||
QStringLiteral("") :
|
||||
QString{} :
|
||||
tr("%1 doesn't support this feature.")
|
||||
.arg(tr(g_video_backend->GetDisplayName().c_str())));
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ void GeneralWidget::OnBackendChanged(const QString& backend_name)
|
||||
m_adapter_combo->setEnabled(supports_adapters && !Core::IsRunning());
|
||||
|
||||
m_adapter_combo->setToolTip(supports_adapters ?
|
||||
QStringLiteral("") :
|
||||
QString{} :
|
||||
tr("%1 doesn't support this feature.")
|
||||
.arg(tr(g_video_backend->GetDisplayName().c_str())));
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ void HacksWidget::OnBackendChanged(const QString& backend_name)
|
||||
|
||||
const QString tooltip = tr("%1 doesn't support this feature on your system.").arg(backend_name);
|
||||
|
||||
m_gpu_texture_decoding->setToolTip(!gpu_texture_decoding ? tooltip : QStringLiteral(""));
|
||||
m_disable_bounding_box->setToolTip(!bbox ? tooltip : QStringLiteral(""));
|
||||
m_gpu_texture_decoding->setToolTip(!gpu_texture_decoding ? tooltip : QString{});
|
||||
m_disable_bounding_box->setToolTip(!bbox ? tooltip : QString{});
|
||||
}
|
||||
|
||||
void HacksWidget::ConnectWidgets()
|
||||
|
||||
@@ -24,19 +24,19 @@ void GCKeyboardEmu::CreateMainLayout()
|
||||
m_main_layout = new QHBoxLayout();
|
||||
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb0x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb0x)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb1x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb1x)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb2x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb2x)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb3x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb3x)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb4x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb4x)));
|
||||
|
||||
auto* vbox_layout = new QVBoxLayout();
|
||||
vbox_layout->addWidget(
|
||||
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb5x)));
|
||||
CreateGroupBox(QString{}, Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb5x)));
|
||||
|
||||
m_main_layout->addLayout(vbox_layout);
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ constexpr int SLIDER_TICK_COUNT = 100;
|
||||
// Escape ampersands and remove ticks
|
||||
static QString ToDisplayString(QString&& string)
|
||||
{
|
||||
return string.replace(QStringLiteral("&"), QStringLiteral("&&"))
|
||||
.replace(QStringLiteral("`"), QStringLiteral(""));
|
||||
return string.replace(QLatin1Char{'&'}, QStringLiteral("&&"))
|
||||
.replace(QLatin1Char{'`'}, QString{});
|
||||
}
|
||||
|
||||
bool MappingButton::IsInput() const
|
||||
|
||||
@@ -33,7 +33,7 @@ QString GetExpressionForControl(const QString& control_name,
|
||||
if (control_device != default_device)
|
||||
{
|
||||
expr += QString::fromStdString(control_device.ToString());
|
||||
expr += QStringLiteral(":");
|
||||
expr += QLatin1Char{':'};
|
||||
}
|
||||
|
||||
// append the control name
|
||||
|
||||
@@ -16,7 +16,7 @@ MappingDouble::MappingDouble(MappingWidget* parent, ControllerEmu::NumericSettin
|
||||
setDecimals(2);
|
||||
|
||||
if (const auto ui_suffix = m_setting.GetUISuffix())
|
||||
setSuffix(QStringLiteral(" ") + tr(ui_suffix));
|
||||
setSuffix(QLatin1Char{' '} + tr(ui_suffix));
|
||||
|
||||
if (const auto ui_description = m_setting.GetUIDescription())
|
||||
setToolTip(tr(ui_description));
|
||||
|
||||
@@ -308,8 +308,8 @@ void MappingWindow::OnGlobalDevicesChanged()
|
||||
{
|
||||
// Selected device is not currently attached.
|
||||
const auto qname = QString::fromStdString(default_device);
|
||||
m_devices_combo->addItem(
|
||||
QStringLiteral("[") + tr("disconnected") + QStringLiteral("] ") + qname, qname);
|
||||
m_devices_combo->addItem(QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + qname,
|
||||
qname);
|
||||
m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1);
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void MappingWindow::SetMappingType(MappingWindow::Type type)
|
||||
case Type::MAPPING_GC_MICROPHONE:
|
||||
widget = new GCMicrophone(this);
|
||||
setWindowTitle(tr("GameCube Microphone Slot %1")
|
||||
.arg(GetPort() == 0 ? QStringLiteral("A") : QStringLiteral("B")));
|
||||
.arg(GetPort() == 0 ? QLatin1Char{'A'} : QLatin1Char{'B'}));
|
||||
AddWidget(tr("Microphone"), widget);
|
||||
break;
|
||||
case Type::MAPPING_WIIMOTE_EMU:
|
||||
|
||||
@@ -160,7 +160,7 @@ void BreakpointWidget::Update()
|
||||
int i = 0;
|
||||
m_table->setRowCount(i);
|
||||
|
||||
auto create_item = [](const QString string = QStringLiteral("")) {
|
||||
const auto create_item = [](const QString string = {}) {
|
||||
QTableWidgetItem* item = new QTableWidgetItem(string);
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
return item;
|
||||
@@ -224,10 +224,10 @@ void BreakpointWidget::Update()
|
||||
QString flags;
|
||||
|
||||
if (mbp.is_break_on_read)
|
||||
flags.append(QStringLiteral("r"));
|
||||
flags.append(QLatin1Char{'r'});
|
||||
|
||||
if (mbp.is_break_on_write)
|
||||
flags.append(QStringLiteral("w"));
|
||||
flags.append(QLatin1Char{'w'});
|
||||
|
||||
m_table->setItem(i, 4, create_item(flags));
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ void CodeViewWidget::OnSelectionChanged()
|
||||
}
|
||||
else if (!styleSheet().isEmpty())
|
||||
{
|
||||
setStyleSheet(QStringLiteral(""));
|
||||
setStyleSheet(QString{});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -314,9 +314,9 @@ void CodeWidget::UpdateCallstack()
|
||||
|
||||
void CodeWidget::UpdateSymbols()
|
||||
{
|
||||
QString selection = m_symbols_list->selectedItems().isEmpty() ?
|
||||
QStringLiteral("") :
|
||||
m_symbols_list->selectedItems()[0]->text();
|
||||
const QString selection = m_symbols_list->selectedItems().isEmpty() ?
|
||||
QString{} :
|
||||
m_symbols_list->selectedItems()[0]->text();
|
||||
m_symbols_list->clear();
|
||||
|
||||
for (const auto& symbol : g_symbolDB.Symbols())
|
||||
|
||||
@@ -169,7 +169,8 @@ void MemoryViewWidget::Update()
|
||||
case Type::ASCII:
|
||||
update_values([&accessors](u32 address) {
|
||||
const char value = accessors->ReadU8(address);
|
||||
return std::isprint(value) ? QString{QChar::fromLatin1(value)} : QStringLiteral(".");
|
||||
return std::isprint(value) ? QString{QChar::fromLatin1(value)} :
|
||||
QString{QChar::fromLatin1('.')};
|
||||
});
|
||||
break;
|
||||
case Type::U16:
|
||||
|
||||
@@ -81,7 +81,7 @@ void RegisterWidget::CreateWidgets()
|
||||
QStringList empty_list;
|
||||
|
||||
for (auto i = 0; i < 9; i++)
|
||||
empty_list << QStringLiteral("");
|
||||
empty_list << QString{};
|
||||
|
||||
m_table->setHorizontalHeaderLabels(empty_list);
|
||||
|
||||
|
||||
@@ -475,7 +475,7 @@ void FIFOAnalyzer::UpdateDescription()
|
||||
text += name.empty() ?
|
||||
QStringLiteral("UNKNOWN_%1").arg(*(cmddata + 1), 2, 16, QLatin1Char('0')) :
|
||||
QString::fromStdString(name);
|
||||
text += QStringLiteral("\n");
|
||||
text += QLatin1Char{'\n'};
|
||||
|
||||
if (desc.empty())
|
||||
text += tr("No description available");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user