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: <https://github.com/nginx/unit/pull/824> Link: <https://github.com/nginx/unit/pull/839> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Tested-by: Liam Crilly <liam@nginx.com> Reviewed-by: Zhidao Hong <z.hong@f5.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
@@ -1540,21 +1540,17 @@ static nxt_http_action_t *
|
|||||||
nxt_http_route_handler(nxt_task_t *task, nxt_http_request_t *r,
|
nxt_http_route_handler(nxt_task_t *task, nxt_http_request_t *r,
|
||||||
nxt_http_action_t *start)
|
nxt_http_action_t *start)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
nxt_http_route_t *route;
|
nxt_http_route_t *route;
|
||||||
nxt_http_action_t *action;
|
nxt_http_action_t *action;
|
||||||
nxt_http_route_match_t **match, **end;
|
|
||||||
|
|
||||||
route = start->u.route;
|
route = start->u.route;
|
||||||
match = &route->match[0];
|
|
||||||
end = match + route->items;
|
|
||||||
|
|
||||||
while (match < end) {
|
for (i = 0; i < route->items; i++) {
|
||||||
action = nxt_http_route_match(task, r, *match);
|
action = nxt_http_route_match(task, r, route->match[i]);
|
||||||
if (action != NULL) {
|
if (action != NULL) {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
match++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nxt_http_request_error(task, r, NXT_HTTP_NOT_FOUND);
|
nxt_http_request_error(task, r, NXT_HTTP_NOT_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user