summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonobject.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-11-27 11:35:13 -0800
committerThiago Macieira <thiago.macieira@intel.com>2022-02-15 17:00:04 -0800
commitc1780165eeca0db6c874866c3184cdaa65542b51 (patch)
tree761227c4a1ce472e4b8c357a2363b0f4abcfd195 /src/corelib/serialization/qjsonobject.cpp
parentdccd1e87f556c4c88044fa0c8a1c2f4f4c151f59 (diff)
QJsonValueConstRef: optimize to{Int,Integer,Bool,Double,String}()
The CBOR-based implementation from Qt 5.15 simply created a QJsonValue and then called the equivalent function on that result. For integrals and double where the QJsonValue matched the asked type, the cost was minimal anyway. For the other types and when the type didn't match, this resulted in up/down the reference counter in QCborContainerPrivate and an out-of-line call to the destructor. This improves the performance for code like: for (QJsonValue v : array) { if (v.toString() == x) { doSomething(); } } This change propagates the inadviseable behavior of allowing a dereference of the end() reference in concrete() to concreteType() (and unit-tests it) but does not do the same for the toXxx() functions. Doing that causes a dereference of QList's end() iterator, which is UB (asserts false in debug mode). Change-Id: I89446ea06b5742efb194fffd16bb3beccd1098e4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
0 files changed, 0 insertions, 0 deletions