refactor(emojis): use std::variant and QStringView (#6714)

This commit is contained in:
Nerixyz
2026-01-05 21:06:42 +01:00
committed by GitHub
parent 327dc0ebcb
commit b7b592098f
8 changed files with 52 additions and 52 deletions
+9 -9
View File
@@ -64,7 +64,7 @@ static void BM_EmojiParsing(benchmark::State &state)
struct TestCase {
QString input;
std::vector<boost::variant<EmotePtr, QString>> expectedOutput;
std::vector<std::variant<EmotePtr, QStringView>> expectedOutput;
};
const auto &emojiMap = emojis.getEmojis();
@@ -89,9 +89,9 @@ static void BM_EmojiParsing(benchmark::State &state)
"foo 🐧 bar",
// expected output
{
"foo ",
u"foo ",
penguinEmoji,
" bar",
u" bar",
},
},
{
@@ -99,7 +99,7 @@ static void BM_EmojiParsing(benchmark::State &state)
"foo bar",
// expected output
{
"foo bar",
u"foo bar",
},
},
{
@@ -107,9 +107,9 @@ static void BM_EmojiParsing(benchmark::State &state)
"foo 🐧 bar 🐧🐧🐧🐧🐧",
// expected output
{
"foo ",
u"foo ",
penguinEmoji,
" bar ",
u" bar ",
penguinEmoji,
penguinEmoji,
penguinEmoji,
@@ -133,9 +133,9 @@ static void BM_EmojiParsing(benchmark::State &state)
qDebug() << "BAD BENCH";
for (const auto &v : output)
{
if (v.type() == typeid(QString))
if (std::holds_alternative<QStringView>(v))
{
qDebug() << "output:" << boost::get<QString>(v);
qDebug() << "output:" << std::get<QStringView>(v);
}
}
}
@@ -158,7 +158,7 @@ static void BM_EmojiParsing2(benchmark::State &state, const QString &input,
int actualNumEmojis = 0;
for (const auto &part : output)
{
if (part.type() == typeid(EmotePtr))
if (std::holds_alternative<EmotePtr>(part))
{
++actualNumEmojis;
}