File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1258,8 +1258,16 @@ bool QgsGeometry::convertToMultiType()
1258
1258
return false ;
1259
1259
}
1260
1260
1261
- multiGeom->addGeometry ( d->geometry ->clone () );
1262
- reset ( std::move ( geom ) );
1261
+ // try to avoid cloning existing geometry whenever we can
1262
+
1263
+ // want to see a magic trick?... gather round kiddies...
1264
+ detach (); // maybe a clone, hopefully not if we're the only ref to the private data
1265
+ // now we cheat a bit and steal the private geometry and add it direct to the multigeom
1266
+ // we can do this because we're the only ref to this geometry, guaranteed by the detach call above
1267
+ multiGeom->addGeometry ( d->geometry .release () );
1268
+ // and replace it with the multi geometry.
1269
+ // TADA! a clone free conversion in some cases
1270
+ d->geometry = std::move ( geom );
1263
1271
return true ;
1264
1272
}
1265
1273
You can’t perform that action at this time.
0 commit comments