Skip to content

Commit 78142b1

Browse files
committed
Simplify code
1 parent 44e6ac2 commit 78142b1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/core/src/main/java/org/locationtech/jts/geom/util/GeometryEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,16 @@ private Geometry editInternal(Geometry geometry, GeometryEditorOperation operati
165165

166166
private Polygon editPolygon(Polygon polygon,
167167
GeometryEditorOperation operation) {
168-
//-- ensure empty polygons are copied
169-
if (polygon.isEmpty()) {
170-
return factory.createPolygon();
171-
}
172168

173169
Polygon newPolygon = (Polygon) operation.edit(polygon, factory);
174-
// create one if needed
170+
// create an empty polygon if needed (which will be removed subsequently if a multi-component)
175171
if (newPolygon == null)
176172
newPolygon = factory.createPolygon();
177173
if (newPolygon.isEmpty()) {
174+
//-- ensure empty polygons are copied
175+
if (newPolygon == polygon) {
176+
newPolygon = factory.createPolygon();
177+
}
178178
return newPolygon;
179179
}
180180

0 commit comments

Comments
 (0)