From 6201b01588fc4bc22d55eb65e5edcec9386b466c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 4 Dec 2025 16:28:34 +0100 Subject: QRMA: clarify performance implications of accessing objects There is no performance difference between accessing mutable or const adapters, but in either case we are going to have to copy the value, as we go through QRM::data() to get a QVariant, which then stores a copy. Change-Id: I1712c3d87002b3650dcfee2900b0d00357695f11 Reviewed-by: Artem Dyomin --- src/corelib/itemmodels/qrangemodeladapter.qdoc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qrangemodeladapter.qdoc b/src/corelib/itemmodels/qrangemodeladapter.qdoc index 5ab128a8c5f..263bff0dd0c 100644 --- a/src/corelib/itemmodels/qrangemodeladapter.qdoc +++ b/src/corelib/itemmodels/qrangemodeladapter.qdoc @@ -118,11 +118,9 @@ would bypass the QAbstractItemModel notification protocol, those reference objects prevent direct modifications of the items. - \note Calling mutable overloads generates some overhead. Make a const copy - of the adapter (which will not copy the data), or use \c{std::as_const} to - make sure that only the const overloads are used in performance critical, - read-heavy code. This is the same technique as when accessing elements in - an implicitly shared Qt container. + \note Accessing the reference object always makes a call to the model to get + a copy of the value. This can be expensive; for performance critical access + to data, store a copy. \section3 Item access -- cgit v1.2.3