Skip to content

Commit

Permalink
Save empty array allocation when no path params exist
Browse files Browse the repository at this point in the history
(cherry picked from commit 66d239a)
  • Loading branch information
geoand authored and gsmet committed May 18, 2022
1 parent 5a44b1b commit c97aee4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

public class RequestMapper<T> {

private static final String[] EMPTY_STRING_ARRAY = new String[0];

private final PathMatcher<List<RequestPath<T>>> requestPaths;
private final PathMatcher.Builder<List<RequestPath<T>>> pathMatcherBuilder;
private final List<RequestPath<T>> templates;
Expand Down Expand Up @@ -59,7 +61,7 @@ public RequestMatch<T> map(String path) {
List<RequestPath<T>> value = initialMatch.getValue();
for (int index = 0; index < value.size(); index++) {
RequestPath<T> potentialMatch = value.get(index);
String[] params = new String[maxParams];
String[] params = (maxParams > 0) ? new String[maxParams] : EMPTY_STRING_ARRAY;
int paramCount = 0;
boolean matched = true;
boolean prefixAllowed = potentialMatch.prefixTemplate;
Expand Down

0 comments on commit c97aee4

Please sign in to comment.