summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2025-09-19 18:41:30 +0200
committerArtem Dyomin <artem.dyomin@qt.io>2025-09-26 16:36:19 +0000
commite7c2c02693dd9d24d602f7afcd47026c3457c25e (patch)
tree70dc3fa4d8a1a37a1ace22be7b0eb6fa2da01659
parentdf01d275f0669891941d44caa3d4ef2fd838be90 (diff)
QRM: apply EBO for storing protocol in QRangeModel
In most cases, the specified protocol is an empty struct, and it's a good style to apply empty-base-optimization for the case. Pick-to: 6.10 Change-Id: I63267b5e217aa08ac46f1d6a2739664d94345210 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/itemmodels/qrangemodel_impl.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/itemmodels/qrangemodel_impl.h b/src/corelib/itemmodels/qrangemodel_impl.h
index 6d8d792878d..ddeeed1b73b 100644
--- a/src/corelib/itemmodels/qrangemodel_impl.h
+++ b/src/corelib/itemmodels/qrangemodel_impl.h
@@ -1019,7 +1019,8 @@ template <typename Structure, typename Range,
typename Protocol = QRangeModelDetails::table_protocol_t<Range>>
class QRangeModelImpl
: public QtPrivate::QQuasiVirtualSubclass<QRangeModelImpl<Structure, Range, Protocol>,
- QRangeModelImplBase>
+ QRangeModelImplBase>,
+ private QtPrivate::CompactStorage<Protocol>
{
public:
using range_type = QRangeModelDetails::wrapped_t<Range>;
@@ -1038,6 +1039,7 @@ public:
>,
typename row_traits::item_type
>;
+ using ProtocolStorage = QtPrivate::CompactStorage<Protocol>;
using const_row_reference = decltype(*std::declval<typename ModelData::const_iterator&>());
@@ -1138,8 +1140,8 @@ protected:
public:
explicit QRangeModelImpl(Range &&model, Protocol&& protocol, QRangeModel *itemModel)
: Ancestor(itemModel)
+ , ProtocolStorage{std::forward<Protocol>(protocol)}
, m_data{std::forward<Range>(model)}
- , m_protocol(std::forward<Protocol>(protocol))
{
}
@@ -2207,11 +2209,10 @@ protected:
}
- const protocol_type& protocol() const { return QRangeModelDetails::refTo(m_protocol); }
- protocol_type& protocol() { return QRangeModelDetails::refTo(m_protocol); }
+ const protocol_type& protocol() const { return QRangeModelDetails::refTo(ProtocolStorage::object()); }
+ protocol_type& protocol() { return QRangeModelDetails::refTo(ProtocolStorage::object()); }
ModelData m_data;
- Protocol m_protocol;
};
// Implementations that depends on the model structure (flat vs tree) that will