aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-20 15:12:29 +0300
committerMarc Mutz <marc.mutz@kdab.com>2019-08-01 15:36:09 +0300
commit6f4475705c95f4c8cf6ab44becae4ad36e34d7bc (patch)
tree4809c5b242cef2e2ccc7ea7833c6e486c506cb85
parentece86693b7bba9092b9b191c9fbe5e2c1ec550a8 (diff)
TCInputMethod: replace a QList with a std::array
The QList always has size 4, so use a std::array instead. Saves more than 1KiB in text size on optimized Linux AMD64 GCC 9.1 builds. Change-Id: I520ea517a3542514f250668adc10938d2fed4778 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/plugins/tcime/plugin/tcinputmethod.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/tcime/plugin/tcinputmethod.cpp b/src/plugins/tcime/plugin/tcinputmethod.cpp
index 73a4b900..3460079d 100644
--- a/src/plugins/tcime/plugin/tcinputmethod.cpp
+++ b/src/plugins/tcime/plugin/tcinputmethod.cpp
@@ -44,6 +44,8 @@
#include <QLibraryInfo>
#include <QFileInfo>
+#include <array>
+
QT_BEGIN_NAMESPACE
namespace QtVirtualKeyboard {
@@ -231,7 +233,7 @@ public:
input.replace(0, 1, c);
} else if (ZhuyinTable::getFinals(QStringView(&c, 1)) > 0) {
// Replace the finals in the decomposed of syllables and tones.
- QList<QChar> decomposed = decomposeZhuyin();
+ std::array<QChar, 4> decomposed = decomposeZhuyin();
if (ZhuyinTable::isYiWuYuFinals(c)) {
decomposed[1] = c;
} else {
@@ -240,9 +242,9 @@ public:
// Compose back the text after the finals replacement.
input.clear();
- for (int i = 0; i < decomposed.length(); ++i) {
- if (!decomposed[i].isNull())
- input.append(decomposed[i]);
+ for (QChar ch : decomposed) {
+ if (!ch.isNull())
+ input.append(ch);
}
} else {
return false;
@@ -258,9 +260,9 @@ public:
return true;
}
- QList<QChar> decomposeZhuyin()
+ std::array<QChar, 4> decomposeZhuyin()
{
- QList<QChar> results = {QChar::Null, QChar::Null, QChar::Null, QChar::Null};
+ std::array<QChar, 4> results = {};
auto strippedTones = ZhuyinTable::stripTones(input);
if (strippedTones.ok) {
// Decompose tones.