fix(rustproxy-routing): reduce hot-path allocations in routing, metrics, and proxy protocol handling

This commit is contained in:
2026-03-16 09:38:55 +00:00
parent 246b44913e
commit a1b8d40011
7 changed files with 116 additions and 51 deletions

View File

@@ -60,6 +60,16 @@ impl RouteManager {
manager
}
/// Check if any route on the given port uses header matching.
/// Used to skip expensive header HashMap construction when no route needs it.
pub fn any_route_has_headers(&self, port: u16) -> bool {
if let Some(indices) = self.port_index.get(&port) {
indices.iter().any(|&idx| self.routes[idx].route_match.headers.is_some())
} else {
false
}
}
/// Find the best matching route for the given context.
pub fn find_route<'a>(&'a self, ctx: &MatchContext<'_>) -> Option<RouteMatchResult<'a>> {
// Get routes for this port