Skip to content

Commit

Permalink
Fix mutation of global state 'InvalidRect64'/'InvalidRectD'
Browse files Browse the repository at this point in the history
by 'GetBounds' variants.
  • Loading branch information
ClaasJG authored and micycle1 committed Oct 22, 2023
1 parent 706ae87 commit a72262f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/clipper2/Clipper.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public static PathsD ReversePaths(PathsD paths) {
}

public static Rect64 GetBounds(Path64 path) {
Rect64 result = InvalidRect64;
Rect64 result = InvalidRect64.clone();
for (Point64 pt : path) {
if (pt.x < result.left) {
result.left = pt.x;
Expand All @@ -696,7 +696,7 @@ public static Rect64 GetBounds(Path64 path) {
}

public static Rect64 GetBounds(Paths64 paths) {
Rect64 result = InvalidRect64;
Rect64 result = InvalidRect64.clone();
for (Path64 path : paths) {
for (Point64 pt : path) {
if (pt.x < result.left) {
Expand All @@ -717,7 +717,7 @@ public static Rect64 GetBounds(Paths64 paths) {
}

public static RectD GetBounds(PathD path) {
RectD result = InvalidRectD;
RectD result = InvalidRectD.clone();
for (PointD pt : path) {
if (pt.x < result.left) {
result.left = pt.x;
Expand All @@ -736,7 +736,7 @@ public static RectD GetBounds(PathD path) {
}

public static RectD GetBounds(PathsD paths) {
RectD result = InvalidRectD;
RectD result = InvalidRectD.clone();
for (PathD path : paths) {
for (PointD pt : path) {
if (pt.x < result.left) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/clipper2/engine/ClipperBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ public static Rect64 GetBounds(Path64 path) {
if (path.isEmpty()) {
return new Rect64();
}
Rect64 result = Clipper.InvalidRect64;
Rect64 result = Clipper.InvalidRect64.clone();
for (Point64 pt : path) {
if (pt.x < result.left) {
result.left = pt.x;
Expand Down Expand Up @@ -2893,7 +2893,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
}

public final Rect64 GetBounds() {
Rect64 bounds = Clipper.InvalidRect64;
Rect64 bounds = Clipper.InvalidRect64.clone();
for (Vertex t : vertexList) {
Vertex v = t;
do {
Expand Down

0 comments on commit a72262f

Please sign in to comment.