Skip to content

Commit

Permalink
Optimise single value map lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
franz1981 committed Dec 11, 2023
1 parent 9d2adeb commit 32248dc
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public class ClassRoutingHandler implements ServerRestHandler {
final boolean resumeOn404;

public ClassRoutingHandler(Map<String, RequestMapper<RuntimeResource>> mappers, int parameterOffset, boolean resumeOn404) {
this.mappers = mappers;
if (mappers.size() == 1) {
var singleEntry = mappers.entrySet().iterator().next();
this.mappers = Map.of(singleEntry.getKey(), singleEntry.getValue());
} else {
this.mappers = mappers;
}
this.parameterOffset = parameterOffset;
this.resumeOn404 = resumeOn404;
}
Expand Down

0 comments on commit 32248dc

Please sign in to comment.