From 9e2b3938671934d2e2e086b13ef1aa7f03cc91d2 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Sun, 12 Jun 2022 09:24:25 +0800 Subject: [PATCH] applets/kicker: store the first char in `firstChar` --- applets/kicker/plugin/appentry.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/applets/kicker/plugin/appentry.cpp b/applets/kicker/plugin/appentry.cpp index 3190c5f6d..3c3c63044 100644 --- a/applets/kicker/plugin/appentry.cpp +++ b/applets/kicker/plugin/appentry.cpp @@ -52,10 +52,13 @@ QString groupName(const QString &name) if (name.isEmpty()) { return QString(); } + + const QChar firstChar = name[0]; + // Here we will apply a locale based strategy for the first character. // If first character is hangul, run decomposition and return the choseong (consonants). - if (name[0].script() == QChar::Script_Hangul) { - auto decomposed = name[0].decomposition(); + if (firstChar.script() == QChar::Script_Hangul) { + auto decomposed = firstChar.decomposition(); if (decomposed.isEmpty()) { return name.left(1); } @@ -66,7 +69,7 @@ QString groupName(const QString &name) // 1. it does not make much sense to have every different Kanji to have a different group. // 2. ICU transliterator can't yet convert Kanji to Hiragana. // https://unicode-org.atlassian.net/browse/ICU-5874 - if (name[0].script() == QChar::Script_Han) { + if (firstChar.script() == QChar::Script_Han) { // Unicode Han return QString::fromUtf8("\xe6\xbc\xa2"); }