[PATCH v4 13/13] Static: optimize "index" iteration

Valentin V. Bartenev vbart at nginx.com
Fri Dec 24 00:24:00 UTC 2021


On Thursday, 23 December 2021 23:14:56 MSK Alejandro Colomar wrote:
> Iterate over "index" only if "share" is a directory.
> 
> Signed-off-by: Alejandro Colomar <alx.manpages at gmail.com>
> Cc: Nginx Unit <unit at nginx.org>
> Cc: "Valentin V. Bartenev" <vbart at nginx.com>
> Cc: Zhidao HONG <z.hong at f5.com>
> Cc: Igor Sysoev <igor at sysoev.ru>
> Cc: Oisin Canty <o.canty at f5.com>
> ---
>  src/nxt_http_static.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/nxt_http_static.c b/src/nxt_http_static.c
> index 30b7fd6..50f63b2 100644
> --- a/src/nxt_http_static.c
> +++ b/src/nxt_http_static.c
> @@ -711,7 +711,13 @@ nxt_http_static_next(nxt_task_t *task, nxt_http_request_t *r,
>      action = ctx->action;
>      conf = action->u.conf;
>  
> -    ctx->index_idx = (ctx->index_idx + 1) % conf->nindices;
> +    if (ctx->share.start[ctx->share.length - 1] == '/') {
> +        ctx->index_idx = (ctx->index_idx + 1) % conf->nindices;
> +
> +    } else {
> +        ctx->index_idx = 0;
> +    }
> +
[..]

What's the reason for this "else"?
Isn't ctx->index_idx always 0 in this case?

--
Valentin





More information about the unit mailing list