Improve ArrayList capacity allocation in GeoJson.

Closes: #4904
Original Pull Request: #4905

Signed-off-by: 정보교 (Bogus Jung) <bogusjung0317@gmail.com>
This commit is contained in:
정보교 (Bogus Jung)
2025-02-22 01:09:30 +09:00
committed by Christoph Strobl
parent c57581f6d2
commit 532dd289ed
2 changed files with 8 additions and 2 deletions

View File

@@ -79,7 +79,7 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> {
Assert.notNull(second, "Second point must not be null");
Assert.notNull(others, "Additional points must not be null");
this.points = new ArrayList<>();
this.points = new ArrayList<>(2 + others.length);
this.points.add(first);
this.points.add(second);
this.points.addAll(Arrays.asList(others));

View File

@@ -130,7 +130,13 @@ public class GeoJsonPolygon extends Polygon implements GeoJson<List<GeoJsonLineS
private static List<Point> asList(Point first, Point second, Point third, Point fourth, Point... others) {
ArrayList<Point> result = new ArrayList<Point>(3 + others.length);
Assert.notNull(first, "First point must not be null");
Assert.notNull(second, "Second point must not be null");
Assert.notNull(third, "Third point must not be null");
Assert.notNull(fourth, "Fourth point must not be null");
Assert.notNull(others, "Additional points must not be null");
ArrayList<Point> result = new ArrayList<Point>(4 + others.length);
result.add(first);
result.add(second);