Skip to content

optimize capacity & add assert messages in GeoJson #3064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* Interface definition for structures defined in <a href="https://geojson.org">GeoJSON</a>
* format. copied from Spring Data Mongodb
* format. copied from Spring Data Mongodb
*
* @author Christoph Strobl
* @since 1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static GeoJsonLineString of(Point first, Point second, Point... others) {
Assert.notNull(second, "Second point must not be null!");
Assert.notNull(others, "Additional points must not be null!");

List<Point> points = new ArrayList<>();
List<Point> points = new ArrayList<>(2 + others.length);
points.add(first);
points.add(second);
points.addAll(Arrays.asList(others));
Expand Down Expand Up @@ -103,7 +103,7 @@ public static GeoJsonLineString of(GeoPoint first, GeoPoint second, GeoPoint...
Assert.notNull(second, "Second point must not be null!");
Assert.notNull(others, "Additional points must not be null!");

List<Point> points = new ArrayList<>();
List<Point> points = new ArrayList<>(2 + others.length);
points.add(GeoPoint.toPoint(first));
points.add(GeoPoint.toPoint(second));
points.addAll(Arrays.stream(others).map(GeoPoint::toPoint).collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static GeoJsonMultiPoint of(Point first, Point second, Point... others) {
Assert.notNull(second, "Second point must not be null!");
Assert.notNull(others, "Additional points must not be null!");

List<Point> points = new ArrayList<>();
List<Point> points = new ArrayList<>(2 + others.length);
points.add(first);
points.add(second);
points.addAll(Arrays.asList(others));
Expand Down Expand Up @@ -103,7 +103,7 @@ public static GeoJsonMultiPoint of(GeoPoint first, GeoPoint second, GeoPoint...
Assert.notNull(second, "Second point must not be null!");
Assert.notNull(others, "Additional points must not be null!");

List<Point> points = new ArrayList<>();
List<Point> points = new ArrayList<>(2 + others.length);
points.add(GeoPoint.toPoint(first));
points.add(GeoPoint.toPoint(second));
points.addAll(Arrays.stream(others).map(GeoPoint::toPoint).collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ public List<GeoJsonLineString> getCoordinates() {
@SafeVarargs
private static <T> List<T> asList(T first, T second, T third, T fourth, T... others) {

ArrayList<T> result = new ArrayList<>(3 + others.length);
Assert.notNull(first, "First element must not be null!");
Assert.notNull(second, "Second element must not be null!");
Assert.notNull(third, "Third element must not be null!");
Assert.notNull(fourth, "Fourth element must not be null!");
Assert.notNull(others, "Additional elements must not be null!");

ArrayList<T> result = new ArrayList<>(4 + others.length);

result.add(first);
result.add(second);
Expand Down