Skip to content

Commit 3d45e61

Browse files
UdjinM6PastaPastaPasta
authored andcommitted
qt: cache translated splash phase labels
1 parent 80fa525 commit 3d45e61

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/qt/splashscreen.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ static const PhaseInfo PHASE_TABLE[] = {
6969
* Uses contains() because ShowProgress may prepend the wallet name. */
7070
static const PhaseInfo* LookupPhase(const QString& message)
7171
{
72-
for (const auto& phase : PHASE_TABLE) {
73-
QString translated = QString::fromStdString(_(phase.msg_key).translated);
72+
static const auto cache = [] {
73+
std::vector<std::pair<const PhaseInfo*, QString>> phases_with_translations;
74+
for (const auto& phase : PHASE_TABLE) {
75+
phases_with_translations.push_back({&phase, QString::fromStdString(_(phase.msg_key).translated)});
76+
}
77+
return phases_with_translations;
78+
}();
79+
80+
for (const auto& [phase, translated] : cache) {
7481
if (message.contains(translated, Qt::CaseInsensitive)) {
75-
return &phase;
82+
return phase;
7683
}
7784
}
7885
return nullptr;

0 commit comments

Comments
 (0)