Browse Source

Improve ArrayList capacity allocation in GeoJson.

Closes: #4904
Original Pull Request: #4905

Signed-off-by: 정보교 (Bogus Jung) <bogusjung0317@gmail.com>
issue/4969
정보교 (Bogus Jung) 10 months ago committed by Christoph Strobl
parent
commit
532dd289ed
No known key found for this signature in database
GPG Key ID: E6054036D0C37A4B
  1. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java
  2. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java

@ -79,7 +79,7 @@ public class GeoJsonMultiPoint implements GeoJson<Iterable<Point>> { @@ -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));

8
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java

@ -130,7 +130,13 @@ public class GeoJsonPolygon extends Polygon implements GeoJson<List<GeoJsonLineS @@ -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);

Loading…
Cancel
Save