From 773c341d70d45a501e6ed4adb0fc6d385423a920 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 10 Jan 2023 22:03:40 +0100 Subject: HTTP: rewrote while loop as for loop. This considerably simplifies the function, and will also help log the iteration in which we are, which corresponds to the route array element. Link: Link: Reviewed-by: Andrew Clayton Tested-by: Liam Crilly Reviewed-by: Zhidao Hong Signed-off-by: Alejandro Colomar --- src/nxt_http_route.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c index 7081ff7e..a4dd8f4a 100644 --- a/src/nxt_http_route.c +++ b/src/nxt_http_route.c @@ -1540,21 +1540,17 @@ static nxt_http_action_t * nxt_http_route_handler(nxt_task_t *task, nxt_http_request_t *r, nxt_http_action_t *start) { + size_t i; nxt_http_route_t *route; nxt_http_action_t *action; - nxt_http_route_match_t **match, **end; route = start->u.route; - match = &route->match[0]; - end = match + route->items; - while (match < end) { - action = nxt_http_route_match(task, r, *match); + for (i = 0; i < route->items; i++) { + action = nxt_http_route_match(task, r, route->match[i]); if (action != NULL) { return action; } - - match++; } nxt_http_request_error(task, r, NXT_HTTP_NOT_FOUND); -- cgit