From 2c235303c2cf303ab0132f75607b044decc3404c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 26 Jun 2015 12:59:51 +0200 Subject: [PATCH] QPlatformFontDatabase: compress an array of ushorts First, all values in the array fit into 8-bit, so change the type from ushort to quint8. Then, instead of appending a zero as end marker, statically determine the size of the array and use that number. Also fixes (benign) off-by-one error in the existing reserve() call. Change-Id: Id05b6a56b55d2e0769b00496a55808bb7351b084 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/text/qplatformfontdatabase.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index ad1aa45446..482495302b 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -40,6 +40,9 @@ #include #include +#include +#include + QT_BEGIN_NAMESPACE void qt_registerFont(const QString &familyname, const QString &stylename, @@ -452,11 +455,11 @@ bool QPlatformFontDatabase::fontsAlwaysScalable() const QList QPlatformFontDatabase::standardSizes() const { QList ret; - static const unsigned short standard[] = - { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72, 0 }; - ret.reserve(int(sizeof(standard) / sizeof(standard[0]))); - const unsigned short *sizes = standard; - while (*sizes) ret << *sizes++; + static const quint8 standard[] = + { 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; + static const int num_standards = int(sizeof standard / sizeof *standard); + ret.reserve(num_standards); + std::copy(standard, standard + num_standards, std::back_inserter(ret)); return ret; }