Context
match_route_compiled in src/state.rs always allocates HashMap<String, String> for path params, even when the route has no :param segments.
Problem
Static routes (the majority in many APIs) pay for an empty HashMap allocation on every request.
Proposed change
- Return
(idx, Option<PathParams>) or use a static empty sentinel / SmallVec for 0–2 params.
- Avoid
HashMap::new() when matchit params iterator is empty.
Files
src/state.rs, src/dispatch.rs, call sites in WebSocket matching
Acceptance criteria
- Routing behaviour unchanged for parameterized and static routes.
- Unit tests for static and dynamic paths.
- Optional microbench shows fewer allocations per match.
Expected low-level impact
Fewer heap allocations on every matched static route.
Context
match_route_compiledinsrc/state.rsalways allocatesHashMap<String, String>for path params, even when the route has no:paramsegments.Problem
Static routes (the majority in many APIs) pay for an empty HashMap allocation on every request.
Proposed change
(idx, Option<PathParams>)or use a static empty sentinel /SmallVecfor 0–2 params.HashMap::new()whenmatchitparams iterator is empty.Files
src/state.rs,src/dispatch.rs, call sites in WebSocket matchingAcceptance criteria
Expected low-level impact
Fewer heap allocations on every matched static route.