diff options
| author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2025-12-04 16:28:34 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2025-12-05 18:10:04 +0100 |
| commit | 6201b01588fc4bc22d55eb65e5edcec9386b466c (patch) | |
| tree | 562bec4734d5da35f697ff4f81c8bf702d00f0f3 /src/corelib | |
| parent | 629f127e9bf5e8cd5c963831d381b5b0f4c2911b (diff) | |
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 <artem.dyomin@qt.io>
Diffstat (limited to 'src/corelib')
| -rw-r--r-- | src/corelib/itemmodels/qrangemodeladapter.qdoc | 8 |
1 files changed, 3 insertions, 5 deletions
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 |
