Skip to content

Commit 3051eca

Browse files
committed
reduce memory usage for PointList.copy, graphhopper#1166
1 parent 77c483f commit 3051eca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/com/graphhopper/util/PointList.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,16 @@ public PointList clone(boolean reverse) {
424424
return clonePL;
425425
}
426426

427+
/**
428+
* This method does a deep copy of this object for the specified range.
429+
*/
427430
public PointList copy(int from, int end) {
428431
if (from > end)
429432
throw new IllegalArgumentException("from must be smaller or equals to end");
430433
if (from < 0 || end > size)
431434
throw new IllegalArgumentException("Illegal interval: " + from + ", " + end + ", size:" + size);
432435

433-
PointList copyPL = new PointList(size, is3D);
436+
PointList copyPL = new PointList(end - from, is3D);
434437
if (is3D)
435438
for (int i = from; i < end; i++) {
436439
copyPL.add(latitudes[i], longitudes[i], elevations[i]);

0 commit comments

Comments
 (0)