From 32248dc9daf5461a06e4ab134a996a32ab056c7a Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Mon, 11 Dec 2023 18:20:53 +0100 Subject: [PATCH] Optimise single value map lookups --- .../reactive/server/handlers/ClassRoutingHandler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java index b46936a7778fd..ec56ad5d7f84c 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/ClassRoutingHandler.java @@ -34,7 +34,12 @@ public class ClassRoutingHandler implements ServerRestHandler { final boolean resumeOn404; public ClassRoutingHandler(Map> 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; }