QOperatingSystemVersion/Android: compress global data

The values do not need to be 2 x 32-bits. Eight bits suffice for a long time to come.

Should save 189 bytes in text size on Android builds.

Change-Id: I78e31e7caa7a698f41c66d7bbac58a766c6e8834
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2017-06-22 21:11:37 +02:00
parent c2a147c3cb
commit e9b44518a6

View File

@ -175,7 +175,10 @@ QOperatingSystemVersion QOperatingSystemVersion::current()
version.m_major = -1;
version.m_minor = -1;
static const int versions[][2] = {
static const struct {
uint major : 4;
uint minor : 4;
} versions[] = {
{ 1, 0 }, // API level 1
{ 1, 1 }, // API level 2
{ 1, 5 }, // API level 3
@ -207,8 +210,8 @@ QOperatingSystemVersion QOperatingSystemVersion::current()
const size_t versionIdx = size_t(QJNIObjectPrivate::getStaticField<jint>(
"android/os/Build$VERSION", "SDK_INT")) - 1;
if (versionIdx < sizeof(versions) / sizeof(versions[0])) {
version.m_major = versions[versionIdx][0];
version.m_minor = versions[versionIdx][1];
version.m_major = versions[versionIdx].major;
version.m_minor = versions[versionIdx].minor;
}
// API level 6 was exactly version 2.0.1