From 4fb196c1d631fbf67b264388760f82498c102e2e Mon Sep 17 00:00:00 2001 From: Jerome Magnin Date: Fri, 21 Feb 2020 10:49:12 +0100 Subject: [PATCH] CLEANUP: sample: use iststop instead of a for loop In sample_fetch_path we can use iststop() instead of a for loop to find the '?' and return the correct length. This requires commit "MINOR: ist: add an iststop() function". --- src/http_fetch.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/http_fetch.c b/src/http_fetch.c index bf4c00680..29a5d17d8 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -982,23 +982,19 @@ static int smp_fetch_path(const struct arg *args, struct sample *smp, const char struct htx *htx = smp_prefetch_htx(smp, chn, 1); struct htx_sl *sl; struct ist path; - size_t len; if (!htx) return 0; sl = http_get_stline(htx); - path = http_get_path(htx_sl_req_uri(sl)); + path = iststop(http_get_path(htx_sl_req_uri(sl)), '?'); if (!path.ptr) return 0; - for (len = 0; len < path.len && *(path.ptr + len) != '?'; len++) - ; - /* OK, we got the '/' ! */ smp->data.type = SMP_T_STR; smp->data.u.str.area = path.ptr; - smp->data.u.str.data = len; + smp->data.u.str.data = path.len; smp->flags = SMP_F_VOL_1ST | SMP_F_CONST; return 1; }