summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-02-09 07:51:12 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-02-10 10:03:37 +0100
commit65b62d2d5c229f0847a3073a72167674e7d23a26 (patch)
tree0b2e961e54d8dc232369d434d0c370be839315f6 /src/gui/painting
parent6586b030d163a4a63328cb83a25dd21411dcbb9e (diff)
QPageSize: pack StandardPageSize struct
On most platforms, the old struct had a padding hole before the FP members, as well as after the character array. By packing the integer members into bit fields, we compress five ints incl. the padding hole (24 bytes) into 64 bits w/o padding (8 bytes). The size of the struct shrinks from 80 to 64 bytes, saving almost 2KiB in TEXT size. Four bytes of tail padding remain, and are available to grow the character array in the future. More compactification could be had by changing the FP members (either by turning them into floats and/or by making them a union over {mm, in}, because one can be calculated from the other), but these are for another patch, because they change return values. Pick-to: 6.3 6.2 Change-Id: I0e7f354a0341e94e9a9401a7d3b4529a8ff20a3d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpagesize.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp
index f69031df8b..5f4c87a106 100644
--- a/src/gui/painting/qpagesize.cpp
+++ b/src/gui/painting/qpagesize.cpp
@@ -224,11 +224,11 @@ static const int qt_windowsConversion[][2] = {
// Standard sizes data
struct StandardPageSize {
- QPageSize::PageSizeId id;
- int windowsId; // Windows DMPAPER value
- QPageSize::Unit definitionUnits; // Standard definition size, e.g. ISO uses mm, ANSI uses inches
- int widthPoints;
- int heightPoints;
+ QPageSize::PageSizeId id : 8;
+ int windowsId : 16; // Windows DMPAPER value
+ QPageSize::Unit definitionUnits : 8; // Standard definition size, e.g. ISO uses mm, ANSI uses inches
+ int widthPoints : 16;
+ int heightPoints : 16;
qreal widthMillimeters;
qreal heightMillimeters;
qreal widthInches;
@@ -386,6 +386,7 @@ static const StandardPageSize qt_pageSizes[] = {
static const int pageSizesCount = int(sizeof(qt_pageSizes) / sizeof(qt_pageSizes[0]));
static_assert(pageSizesCount == QPageSize::LastPageSize + 1);
+static_assert(QPageSize::LastPageSize < 256);
// Return key name for PageSize
static QString qt_keyForPageSizeId(QPageSize::PageSizeId id)