... you are too slow and QJson API is so ugly.
Now using this wonderful json lib:
https://github.com/nlohmann/json
Results in release mode (QJson tests are not shown but
QJson was even slower than string concat).
PASS : TestQgsJsonUtils::testExportAttributesJson(Use json)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use json":
0.0022 msecs per iteration (total: 75, iterations: 32768)
PASS : TestQgsJsonUtils::testExportAttributesJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportAttributesJson():"Use old string concat":
0.0032 msecs per iteration (total: 54, iterations: 16384)
PASS : TestQgsJsonUtils::testExportFeatureJson(Use json)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use json":
0.011 msecs per iteration (total: 96, iterations: 8192)
PASS : TestQgsJsonUtils::testExportFeatureJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportFeatureJson():"Use old string concat":
0.015 msecs per iteration (total: 64, iterations: 4096)
PASS : TestQgsJsonUtils::testExportGeomToJson(Use json)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use json":
0.76 msecs per iteration (total: 98, iterations: 128)
PASS : TestQgsJsonUtils::testExportGeomToJson(Use old string concat)
RESULT : TestQgsJsonUtils::testExportGeomToJson():"Use old string concat":
0.85 msecs per iteration (total: 55, iterations: 64)
PASS : TestQgsJsonUtils::cleanupTestCase()
This class is a new subclass of QgsGeometryCheck that implements an interface that works on isolated geometries.
It has no dependency on a context, apart from a configuration that can be passed in. This makes it suitable
for checks that only work on in-memory information like self-intersection and other isValid checks.
For reference the classes QgsGeometrySelfIntersectionCheck, QgsGeometryMultipartCheck, QgsGeometryTypeCheck
and QgsGeometrySelfContactCheck have been ported to this interface.
QgsFeaturePool is now an abstract baseclass, with a new inherited class QgsVectorDataProviderFeaturePool. This allows creating other subclasses, most notably a QgsVectorLayerFeaturePool subclass, that is able to also work on uncommitted features.
Critical calls to methods which are not threadsafe have been protected by executing them on the main thread.
Because feature.geometry().geometry() is confusing, and impossible
to search for in python code (e.g. is input.geometry() a QgsGeometry
or a QgsAbstractGeometry?)
But more importantantly: also add a const version
QgsGeometry::constGet(). The non-const
version is slow, since it now forces a detach to avoid corrupting
geometries (since QgsGeometry is shared, it's not safe to directly
access its primitive QgsAbstractGeometry and start messing with
it without first detaching). This is a big risk in the 2.x API
which could potentially corrupt feature geometries with unexpected
outcomes.
Update all uses to constGet where possible.