From fef1b84f0a587dc285af6659cb64042e34e54223 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 30 Jul 2019 07:57:06 -0400 Subject: 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. --- Source/Core/DolphinQt/Config/CheatCodeEditor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Source/Core/DolphinQt/Config/CheatCodeEditor.cpp') diff --git a/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp b/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp index 1292e0272d..0ed6bf7ba9 100644 --- a/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp +++ b/Source/Core/DolphinQt/Config/CheatCodeEditor.cpp @@ -124,7 +124,7 @@ bool CheatCodeEditor::AcceptAR() std::vector entries; std::vector 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 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 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); -- cgit v1.2.3