diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-06-26 12:59:51 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-16 13:21:15 +0000 |
commit | 2c235303c2cf303ab0132f75607b044decc3404c (patch) | |
tree | 27f85169272a782a6a3d79d6c38fe629df08b3e6 /src/gui | |
parent | 0b43c0a74346f3a58d8aee625d8271741b03563a (diff) |
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) <ogoffart@woboq.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qplatformfontdatabase.cpp | 13 |
1 files 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 <QtCore/QLibraryInfo> #include <QtCore/QDir> +#include <algorithm> +#include <iterator> + QT_BEGIN_NAMESPACE void qt_registerFont(const QString &familyname, const QString &stylename, @@ -452,11 +455,11 @@ bool QPlatformFontDatabase::fontsAlwaysScalable() const QList<int> QPlatformFontDatabase::standardSizes() const { QList<int> 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; } |