Repository: FreeCAD/FreeCAD
File: src/Mod/Sketcher/App/SketchObject.cpp (C++)

Code before:
            }

            Objects.push_back(sobj);
            SubElements.push_back(sSubElements[si]);

            si++;
        }

        ExternalGeometry.setValues(Objects, SubElements);

        try {
            rebuildExternalGeometry();
        }
        catch (const Base::Exception& e) {
            Base::Console().error("%s\n", e.what());
            // revert to original values
            ExternalGeometry.setValues(originalObjects, originalSubElements);
            return -1;
        }

        solverNeedsUpdate = true;
    }

    auto applyGeometryFlipCorrection = [xinv, yinv, origin, axisV, axisH]
                                       (Part::Geometry* geoNew) {
        if (!(xinv || yinv)) {
            return;
        }

        if (xinv) {
            geoNew->mirror(origin, axisV);
        }
        if (yinv) {
            geoNew->mirror(origin, axisH);
        }
    };

    for (std::vector<Part::Geometry*>::const_iterator it = svals.begin(); it != svals.end(); ++it) {
        Part::Geometry* geoNew = (*it)->copy();
        if (xinv || yinv) {
            // corrections for flipped geometry
            applyGeometryFlipCorrection(geoNew);
        }
        generateId(geoNew);
        if (construction && !geoNew->is<Part::GeomPoint>()) {
            GeometryFacade::setConstruction(geoNew, true);
        }
        newVals.push_back(geoNew);
    }

    auto applyConstraintFlipCorrection = [xinv, yinv]

Review comment (suggestion):
Let's not complicate logic too much - nested logic is harder to process.

```suggestion
        if (!xinv && !yinv) {
```

Code after:

                i++;
            }

            Objects.push_back(sobj);
            SubElements.push_back(sSubElements[si]);

            si++;
        }

        ExternalGeometry.setValues(Objects, SubElements);

        try {
            rebuildExternalGeometry();
        }
        catch (const Base::Exception& e) {
            Base::Console().error("%s\n", e.what());
            // revert to original values
            ExternalGeometry.setValues(originalObjects, originalSubElements);
            return -1;
        }

        solverNeedsUpdate = true;
    }

    auto applyGeometryFlipCorrection = [xinv, yinv, origin, axisV, axisH]
                                       (Part::Geometry* geoNew) {
        if (!xinv && !yinv) {
            return;
        }

        if (xinv) {
            geoNew->mirror(origin, axisV);
        }
        if (yinv) {
            geoNew->mirror(origin, axisH);
        }
    };

    for (std::vector<Part::Geometry*>::const_iterator it = svals.begin(); it != svals.end(); ++it) {
        Part::Geometry* geoNew = (*it)->copy();
        if (xinv || yinv) {
            // corrections for flipped geometry
            applyGeometryFlipCorrection(geoNew);
        }
        generateId(geoNew);
        if (construction && !geoNew->is<Part::GeomPoint>()) {
            GeometryFacade::setConstruction(geoNew, true);
        }
        newVals.push_back(geoNew);
    }