Convert Routes to Handler in ServerInboundHandler to avoid allocations & method invocations each time we call Routes#apply.
Store the wildcards tree in RoutePattern in a val to avoid doing that on each invocation to RoutePattern#get
Use Map#getOrElse(key, null) in a couple of places
Extract tree outside of the Function1 in toHandler to avoid checking the class var on each request
Use null as the default for Set[Int] in PathCodec#get. This avoids the boxing of the Int on each iteration.
Note on (5): We could also use BitSet here, but since almost always skipLiteralsFor will be empty / null, it's better to avoid the method invocation and just do a null check
Main changes:
Routes
toHandler
inServerInboundHandler
to avoid allocations & method invocations each time we callRoutes#apply
.RoutePattern
in a val to avoid doing that on each invocation toRoutePattern#get
Map#getOrElse(key, null)
in a couple of placestree
outside of theFunction1
intoHandler
to avoid checking the classvar
on each requestnull
as the default forSet[Int]
inPathCodec#get
. This avoids the boxing of the Int on each iteration.Note on (5): We could also use
BitSet
here, but since almost alwaysskipLiteralsFor
will be empty / null, it's better to avoid the method invocation and just do a null check