From d2e3f003676c703ebafb00bc7765070dffa65f1a Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 2 Jul 2020 18:37:26 +0200 Subject: Clean up data members and initialization in QAbstractSpinBox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Group the bit flags together and generally order roughly by size to give the compiler better packing options. Change-Id: I9468d5aaef96e115ad363c59222e626d792a0edc Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qabstractspinbox.cpp | 12 +++------- src/widgets/widgets/qabstractspinbox_p.h | 39 ++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 26 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index bdda50603b..f87e4d1a2a 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1425,15 +1425,9 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event) */ QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() - : edit(nullptr), type(QMetaType::UnknownType), spinClickTimerId(-1), - spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1), - effectiveSpinRepeatRate(1), buttonState(None), keyboardModifiers{}, cachedText(QLatin1String("\x01")), - cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), - ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), - cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), - stepModifier(Qt::ControlModifier), acceleration(0), hoverControl(QStyle::SC_None), - buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(nullptr), showGroupSeparator(0), - wheelDeltaRemainder(0) + : pendingEmit(false), readOnly(false), wrapping(false), + ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), + cleared(false), ignoreUpdateEdit(false), showGroupSeparator(false) { } diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index aa9ec4d646..bfde96372c 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -124,18 +124,32 @@ public: virtual QVariant calculateAdaptiveDecimalStep(int steps) const; - QLineEdit *edit; QString prefix, suffix, specialValueText; QVariant value, minimum, maximum, singleStep; - QMetaType::Type type; - int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval; - int effectiveSpinRepeatRate; - uint buttonState; - Qt::KeyboardModifiers keyboardModifiers; - mutable QString cachedText; + QRect hoverRect; + + mutable QString cachedText = QLatin1String("\x01"); mutable QVariant cachedValue; - mutable QValidator::State cachedState; mutable QSize cachedSizeHint, cachedMinimumSizeHint; + QLineEdit *edit = nullptr; + QSpinBoxValidator *validator = nullptr; + QMetaType::Type type = QMetaType::UnknownType; + int spinClickTimerId = -1; + int spinClickTimerInterval = 100; + int spinClickThresholdTimerId = -1; + int spinClickThresholdTimerInterval = -1; + int effectiveSpinRepeatRate = 1; + int acceleration = 0; + int wheelDeltaRemainder = 0; + + Qt::KeyboardModifiers keyboardModifiers = Qt::NoModifier; + Qt::KeyboardModifier stepModifier = Qt::ControlModifier; + QAbstractSpinBox::CorrectionMode correctionMode = QAbstractSpinBox::CorrectToPreviousValue; + QAbstractSpinBox::StepType stepType = QAbstractSpinBox::StepType::DefaultStepType; + QAbstractSpinBox::ButtonSymbols buttonSymbols = QAbstractSpinBox::UpDownArrows; + QStyle::SubControl hoverControl = QStyle::SC_None; + mutable QValidator::State cachedState = QValidator::Invalid; + uint buttonState = None; uint pendingEmit : 1; uint readOnly : 1; uint wrapping : 1; @@ -145,16 +159,7 @@ public: uint keyboardTracking : 1; uint cleared : 1; uint ignoreUpdateEdit : 1; - QAbstractSpinBox::CorrectionMode correctionMode; - QAbstractSpinBox::StepType stepType = QAbstractSpinBox::StepType::DefaultStepType; - Qt::KeyboardModifier stepModifier = Qt::ControlModifier; - int acceleration; - QStyle::SubControl hoverControl; - QRect hoverRect; - QAbstractSpinBox::ButtonSymbols buttonSymbols; - QSpinBoxValidator *validator; uint showGroupSeparator : 1; - int wheelDeltaRemainder; }; class QSpinBoxValidator : public QValidator -- cgit v1.2.3