From e1c31494f2076b6d03adcc015dee040ed35c4210 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Thu, 22 Feb 2018 11:10:51 +0800 Subject: [PATCH] ISSUES-995 resolve some opinions --- dbms/src/Functions/FunctionsURL.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dbms/src/Functions/FunctionsURL.h b/dbms/src/Functions/FunctionsURL.h index 0614f66a809..bd1ba3be5d0 100644 --- a/dbms/src/Functions/FunctionsURL.h +++ b/dbms/src/Functions/FunctionsURL.h @@ -100,26 +100,26 @@ inline StringView getURLHost(const StringView & url) Pos scheme_end = url.data() + scheme.size(); // Colon must follows after scheme. - if (*(scheme_end++) != ':' || scheme_end != pos) + if (pos - scheme_end != 1 || *scheme_end != ':') return StringView(); } - if (end - pos < 2 || *(pos++) != '/' || *(pos++) != '/') + if (end - pos < 2 || *(pos) != '/' || *(pos + 1) != '/') return StringView(); - const char *st = pos; + const char *start_of_host = (pos += 2); for (; pos < end; ++pos) { if (*pos == '@') { - st = pos + 1; + start_of_host = pos + 1; } else if (*pos == ':' || *pos == '/' || *pos == '?' || *pos == '#') { break; } } - return (pos == st) ? StringView() : StringView(st, pos - st); + return (pos == start_of_host) ? StringView() : StringView(start_of_host, pos - start_of_host); } @@ -408,25 +408,24 @@ struct ExtractWWW return; } - if (end - pos < 2 || *(pos++) != '/' || *(pos++) != '/') + if (end - pos < 2 || *(pos) != '/' || *(pos + 1) != '/') return; - const char *st = pos; + const char *start_of_host = (pos += 2); for (; pos < end; ++pos) { if (*pos == '@') { - st = pos + 1; + start_of_host = pos + 1; } else if (*pos == ':' || *pos == '/' || *pos == '?' || *pos == '#') { break; } } - - if (st + 4 < end && !strncmp(st, "www.", 4)) + if (start_of_host + 4 < end && !strncmp(start_of_host, "www.", 4)) { - res_data = st; + res_data = start_of_host; res_size = 4; } }