protocol: simpler Curl_getn_scheme runs faster
No binary (build failed)
—
(log yok)
| @@ -17,6 +17,7 @@ codespell \ | |
| --skip 'RELEASE-NOTES' \ | |
| --skip 'scripts/wcurl' \ | |
| --skip 'tests/unit/unit1625.c' \ | |
| + | --skip 'tests/unit/unit1627.c' \ |
| --ignore-regex '.*spellchecker:disable-line' \ | |
| --ignore-words '.github/scripts/codespell-ignore.words' \ | |
| -- | |
| @@ -35,4 +35,5 @@ extend-exclude = [ | |
| "scripts/wcurl", | |
| "tests/data/test*", | |
| "tests/unit/unit1625.c", | |
| + | "tests/unit/unit1627.c", |
| ] | |
| @@ -462,72 +462,199 @@ const struct Curl_scheme Curl_scheme_wss = { | |
| PORT_HTTPS /* defport */ | |
| }; | |
| + | |
| + | static const struct Curl_scheme *two_letter_scheme(const char *scheme) |
| + | { |
| + | if((Curl_raw_tolower(scheme[0]) == 'w') && |
| + | (Curl_raw_tolower(scheme[1]) == 's')) |
| + | return &Curl_scheme_ws; |
| + | return NULL; |
| + | } |
| + | |
| + | static const struct Curl_scheme *three_letter_scheme(const char *scheme) |
| + | { |
| + | char s0 = Curl_raw_tolower(scheme[0]); |
| + | char s1 = Curl_raw_tolower(scheme[1]); |
| + | char s2 = Curl_raw_tolower(scheme[2]); |
| + | if(s0 == 'f') { |
| + | if(s1 == 't' && s2 == 'p') |
| + | return &Curl_scheme_ftp; |
| + | } |
| + | else if(s0 == 'w') { |
| + | if(s1 == 's' && s2 == 's') |
| + | return &Curl_scheme_wss; |
| + | } |
| + | else if(s0 == 's') { |
| + | if(s1 == 'c' && s2 == 'p') |
| + | return &Curl_scheme_scp; |
| + | if(s1 == 'm' && s2 == 'b') |
| + | return &Curl_scheme_smb; |
| + | } |
| + | return NULL; |
| + | } |
| + | |
| + | static const struct Curl_scheme *four_letter_scheme(const char *scheme) |
| + | { |
| + | char s0 = Curl_raw_tolower(scheme[0]); |
| + | char s1 = Curl_raw_tolower(scheme[1]); |
| + | char s2 = Curl_raw_tolower(scheme[2]); |
| + | char s3 = Curl_raw_tolower(scheme[3]); |
| + | if(s3 == 'p') { |
| + | if(s0 == 'h') { |
| + | if(s1 == 't' && s2 == 't') |
| + | return &Curl_scheme_http; |
| + | } |
| + | else if(s0 == 'i') { |
| + | if(s1 == 'm' && s2 == 'a') |
| + | return &Curl_scheme_imap; |
| + | } |
| + | else if(s0 == 'l') { |
| + | if(s1 == 'd' && s2 == 'a') |
| + | return &Curl_scheme_ldap; |
| + | } |
| + | else if(s0 == 'r') { |
| + | if(s1 == 't' && s2 == 's') |
| + | return &Curl_scheme_rtsp; |
| + | } |
| + | else if(s0 == 't') { |
| + | if(s1 == 'f' && s2 == 't') |
| + | return &Curl_scheme_tftp; |
| + | } |
| + | else if(s0 == 's') { |
| + | if(s1 == 'f' && s2 == 't') |
| + | return &Curl_scheme_sftp; |
| + | if(s1 == 'm' && s2 == 't') |
| + | return &Curl_scheme_smtp; |
| + | } |
| + | } |
| + | else if(s0 == 'f') { |
| + | if(s1 == 't' && s2 == 'p' && s3 == 's') |
| + | return &Curl_scheme_ftps; |
| + | if(s1 == 'i' && s2 == 'l' && s3 == 'e') |
| + | return &Curl_scheme_file; |
| + | } |
| + | else if(s0 == 'm') { |
| + | if(s1 == 'q' && s2 == 't' && s3 == 't') |
| + | return &Curl_scheme_mqtt; |
| + | } |
| + | else if(s0 == 'p') { |
| + | if(s1 == 'o' && s2 == 'p' && s3 == '3') |
| + | return &Curl_scheme_pop3; |
| + | } |
| + | else if(s0 == 'd') { |
| + | if(s1 == 'i' && s2 == 'c' && s3 == 't') |
| + | return &Curl_scheme_dict; |
| + | } |
| + | else if(s0 == 's') { |
| + | if(s1 == 'm' && s2 == 'b' && s3 == 's') |
| + | return &Curl_scheme_smbs; |
| + | } |
| + | return NULL; |
| + | } |
| + | |
| + | static const struct Curl_scheme *five_letter_scheme(const char *scheme) |
| + | { |
| + | char s4 = Curl_raw_tolower(scheme[4]); |
| + | if(s4 == 's') { |
| + | char s0 = Curl_raw_tolower(scheme[0]); |
| + | char s1 = Curl_raw_tolower(scheme[1]); |
| + | char s2 = Curl_raw_tolower(scheme[2]); |
| + | char s3 = Curl_raw_tolower(scheme[3]); |
| + | if(s3 == 'p') { |
| + | switch(s0) { |
| + | case 'h': |
| + | if(s1 == 't' && s2 == 't') |
| + | return &Curl_scheme_https; |
| + | break; |
| + | case 'l': |
| + | if(s1 == 'd' && s2 == 'a') |
| + | return &Curl_scheme_ldaps; |
| + | break; |
| + | case 'i': |
| + | if(s1 == 'm' && s2 == 'a') |
| + | return &Curl_scheme_imaps; |
| + | break; |
| + | case 's': |
| + | if(s1 == 'm' && s2 == 't') |
| + | return &Curl_scheme_smtps; |
| + | break; |
| + | default: |
| + | break; |
| + | } |
| + | } |
| + | else if(s0 == 'p') { |
| + | if(s1 == 'o' && s2 == 'p' && s3 == '3') |
| + | return &Curl_scheme_pop3s; |
| + | } |
| + | else if(s0 == 'm') { |
| + | if(s1 == 'q' && s2 == 't' && s3 == 't') |
| + | return &Curl_scheme_mqtts; |
| + | } |
| + | else if(s0 == 's') { |
| + | if(s1 == 'o' && s2 == 'c' && s3 == 'k') |
| + | return &Curl_scheme_socks; |
| + | } |
| + | } |
| + | return NULL; |
| + | } |
| + | |
| + | static const struct Curl_scheme *six_letter_scheme(const char *scheme) |
| + | { |
| + | char s0 = Curl_raw_tolower(scheme[0]); |
| + | switch(s0) { |
| + | case 's': |
| + | if(curl_strnequal("ocks4", &scheme[1], 5)) |
| + | return &Curl_scheme_socks4; |
| + | if(curl_strnequal("ocks5", &scheme[1], 5)) |
| + | return &Curl_scheme_socks5; |
| + | break; |
| + | case 'g': |
| + | if(curl_strnequal("opher", &scheme[1], 5)) |
| + | return &Curl_scheme_gopher; |
| + | break; |
| + | case 't': |
| + | if(curl_strnequal("elnet", &scheme[1], 5)) |
| + | return &Curl_scheme_telnet; |
| + | break; |
| + | } |
| + | return NULL; |
| + | } |
| + | |
| + | static const struct Curl_scheme *seven_letter_scheme(const char *scheme) |
| + | { |
| + | char s0 = Curl_raw_tolower(scheme[0]); |
| + | if(s0 == 's') { |
| + | if(curl_strnequal("ocks4a", &scheme[1], 6)) |
| + | return &Curl_scheme_socks4a; |
| + | if(curl_strnequal("ocks5h", &scheme[1], 6)) |
| + | return &Curl_scheme_socks5h; |
| + | } |
| + | else if(s0 == 'g') { |
| + | if(curl_strnequal("ophers", &scheme[1], 6)) |
| + | return &Curl_scheme_gophers; |
| + | } |
| + | return NULL; |
| + | } |
| + | |
| /* Returns a struct scheme pointer if the name is a known scheme. Check the | |
| ->run struct field for non-NULL to figure out if an implementation is | |
| present. */ | |
| const struct Curl_scheme *Curl_getn_scheme(const char *scheme, size_t len) | |
| { | |
| - | /* table generated by schemetable.c: |
| - | 1. gcc schemetable.c && ./a.out |
| - | 2. check how small the table gets |
| - | 3. tweak the hash algorithm, then rerun from 1 |
| - | 4. when the table is good enough |
| - | 5. copy the table into this source code |
| - | 6. make sure this function uses the same hash function that worked for |
| - | schemetable.c |
| - | */ |
| - | static const struct Curl_scheme * const all_schemes[59] = { NULL, |
| - | &Curl_scheme_pop3, NULL, |
| - | &Curl_scheme_smtps, |
| - | &Curl_scheme_socks, |
| - | &Curl_scheme_socks4, |
| - | &Curl_scheme_socks5, NULL, NULL, |
| - | &Curl_scheme_gophers, |
| - | &Curl_scheme_ws, |
| - | &Curl_scheme_sftp, |
| - | &Curl_scheme_socks4a, |
| - | &Curl_scheme_scp, |
| - | &Curl_scheme_rtsp, |
| - | &Curl_scheme_dict, NULL, NULL, |
| - | &Curl_scheme_gopher, NULL, NULL, NULL, |
| - | &Curl_scheme_wss, NULL, |
| - | &Curl_scheme_smb, NULL, |
| - | &Curl_scheme_ldap, |
| - | &Curl_scheme_ldaps, |
| - | &Curl_scheme_imap, NULL, NULL, NULL, |
| - | &Curl_scheme_imaps, |
| - | &Curl_scheme_https, |
| - | &Curl_scheme_tftp, |
| - | &Curl_scheme_telnet, NULL, NULL, NULL, |
| - | &Curl_scheme_file, |
| - | &Curl_scheme_smtp, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
| - | &Curl_scheme_ftp, |
| - | &Curl_scheme_mqtt, NULL, |
| - | &Curl_scheme_socks5h, |
| - | &Curl_scheme_http, |
| - | &Curl_scheme_pop3s, NULL, |
| - | &Curl_scheme_mqtts, NULL, |
| - | &Curl_scheme_smbs, |
| - | &Curl_scheme_ftps, |
| + | typedef const struct Curl_scheme *(*letterfunc)(const char *ptr); |
| + | static const letterfunc parse[] = { |
| + | two_letter_scheme, |
| + | three_letter_scheme, |
| + | four_letter_scheme, |
| + | five_letter_scheme, |
| + | six_letter_scheme, |
| + | seven_letter_scheme |
| }; | |
| - | if(len && (len <= 7)) { |
| - | const char *s = scheme; |
| - | size_t l = len; |
| - | const struct Curl_scheme *h; |
| - | unsigned int c = 443; |
| - | while(l) { |
| - | c <<= 5; |
| - | c += (unsigned int)Curl_raw_tolower(*s); |
| - | s++; |
| - | l--; |
| - | } |
| + | if(len < 2 || len > 7) |
| + | return NULL; |
| - | h = all_schemes[c % 59]; |
| - | if(h && curl_strnequal(scheme, h->name, len) && !h->name[len]) |
| - | return h; |
| - | } |
| - | return NULL; |
| + | return parse[len - 2](scheme); |
| } | |
| const struct Curl_scheme *Curl_get_scheme(const char *scheme) | |
| @@ -23,7 +23,7 @@ | |
| ########################################################################### | |
| EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl \ | |
| - | checksrc-all.pl mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd \ |
| + | checksrc-all.pl mk-ca-bundle.pl mk-unity.pl cd2nroff nroff2cd \ |
| cdall cd2cd managen dmaketgz maketgz release-tools.sh verify-release \ | |
| cmakelint.sh cmakeopts.sh mdlinkcheck CMakeLists.txt perlcheck.sh \ | |
| pythonlint.sh spacecheck.pl randdisable wcurl top-complexity \ | |
| @@ -1,186 +0,0 @@ | |
| - | /*************************************************************************** |
| - | * _ _ ____ _ |
| - | * Project ___| | | | _ \| | |
| - | * / __| | | | |_) | | |
| - | * | (__| |_| | _ <| |___ |
| - | * \___|\___/|_| \_\_____| |
| - | * |
| - | * Copyright (C) Daniel Stenberg, <[email protected]>, et al. |
| - | * |
| - | * This software is licensed as described in the file COPYING, which |
| - | * you should have received as part of this distribution. The terms |
| - | * are also available at https://curl.se/docs/copyright.html. |
| - | * |
| - | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| - | * copies of the Software, and permit persons to whom the Software is |
| - | * furnished to do so, under the terms of the COPYING file. |
| - | * |
| - | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| - | * KIND, either express or implied. |
| - | * |
| - | * SPDX-License-Identifier: curl |
| - | * |
| - | ***************************************************************************/ |
| - | #include <stdio.h> |
| - | #include <curl/curl.h> |
| - | |
| - | /* |
| - | * Use this tool to generate an updated table for the Curl_getn_scheme_handler |
| - | * function in url.c. |
| - | */ |
| - | |
| - | static const char * const scheme[] = { |
| - | "dict", |
| - | "file", |
| - | "ftp", |
| - | "ftps", |
| - | "gopher", |
| - | "gophers", |
| - | "http", |
| - | "https", |
| - | "imap", |
| - | "imaps", |
| - | "ldap", |
| - | "ldaps", |
| - | "mqtt", |
| - | "mqtts", |
| - | "pop3", |
| - | "pop3s", |
| - | "rtsp", |
| - | "scp", |
| - | "sftp", |
| - | "smb", |
| - | "smbs", |
| - | "smtp", |
| - | "smtps", |
| - | "socks", |
| - | "socks4", |
| - | "socks4a", |
| - | "socks5", |
| - | "socks5h", |
| - | "telnet", |
| - | "tftp", |
| - | "ws", |
| - | "wss", |
| - | NULL, |
| - | }; |
| - | |
| - | unsigned int calc(const char *s, int add, int shift) |
| - | { |
| - | const char *so = s; |
| - | unsigned int c = add; |
| - | while(*s) { |
| - | c <<= shift; |
| - | c += *s; |
| - | s++; |
| - | } |
| - | return c; |
| - | } |
| - | |
| - | unsigned int num[100]; |
| - | unsigned int ix[100]; |
| - | |
| - | static void showtable(int try, int init, int shift) |
| - | { |
| - | int nulls = 0; |
| - | int i; |
| - | for(i = 0; scheme[i]; ++i) |
| - | num[i] = calc(scheme[i], init, shift); |
| - | for(i = 0; scheme[i]; ++i) |
| - | ix[i] = num[i] % try; |
| - | printf("/*\n" |
| - | " unsigned int c = %d\n" |
| - | " while(l) {\n" |
| - | " c <<= %d;\n" |
| - | " c += Curl_raw_tolower(*s);\n" |
| - | " s++;\n" |
| - | " l--;\n" |
| - | " }\n" |
| - | "*/\n", |
| - | init, shift); |
| - | |
| - | printf(" static const struct Curl_scheme * const all_schemes[%d] = {", try); |
| - | |
| - | /* generate table */ |
| - | for(i = 0; i < try; i++) { |
| - | int match = 0; |
| - | int j; |
| - | for(j = 0; scheme[j]; j++) { |
| - | if(ix[j] == i) { |
| - | printf("\n &Curl_scheme_%s,", scheme[j]); |
| - | match = 1; |
| - | nulls = 0; |
| - | break; |
| - | } |
| - | } |
| - | if(!match) |
| - | printf(" NULL,"); |
| - | } |
| - | printf("\n };\n"); |
| - | } |
| - | |
| - | int main(void) |
| - | { |
| - | int i; |
| - | int try; |
| - | int besttry = 9999; |
| - | int bestadd = 0; |
| - | int bestshift = 0; |
| - | int add; |
| - | int shift; |
| - | for(shift = 0; shift < 8; shift++) { |
| - | for(add = 0; add < 999; add++) { |
| - | for(i = 0; scheme[i]; ++i) { |
| - | unsigned int v = calc(scheme[i], add, shift); |
| - | int j; |
| - | int badcombo = 0; |
| - | for(j = 0; j < i; j++) { |
| - | |
| - | if(num[j] == v) { |
| - | #if 0 |
| - | printf("NOPE: %u is a dupe (%s and %s)\n", |
| - | v, scheme[i], scheme[j]); |
| - | #endif |
| - | badcombo = 1; |
| - | break; |
| - | } |
| - | } |
| - | if(badcombo) |
| - | break; |
| - | num[i] = v; |
| - | } |
| - | #if 0 |
| - | for(i = 0; scheme[i].n; ++i) { |
| - | printf("%u - %s\n", num[i], scheme[i].n); |
| - | } |
| - | #endif |
| - | /* try different remainders to find smallest possible table */ |
| - | for(try = 28; try < 199; try++) { |
| - | int good = 1; |
| - | for(i = 0; scheme[i]; ++i) { |
| - | ix[i] = num[i] % try; |
| - | } |
| - | /* check for dupes */ |
| - | for(i = 0; scheme[i] && good; ++i) { |
| - | int j; |
| - | for(j = 0; j < i; j++) { |
| - | if(ix[j] == ix[i]) { |
| - | good = 0; |
| - | break; |
| - | } |
| - | } |
| - | } |
| - | if(good) { |
| - | if(try < besttry) { |
| - | besttry = try; |
| - | bestadd = add; |
| - | bestshift = shift; |
| - | } |
| - | break; |
| - | } |
| - | } |
| - | } |
| - | } |
| - | |
| - | showtable(besttry, bestadd, bestshift); |
| - | } |
| @@ -18,7 +18,7 @@ Curl_get_scheme unit test | |
| <verify> | |
| <stdout mode="text"> | |
| - | 199 invokes |
| + | 547 invokes |
| </stdout> | |
| </verify> | |
| </testcase> | |
| @@ -26,11 +26,13 @@ | |
| #include "url.h" | |
| #include "strcase.h" | |
| + | #define ITERATIONS1627 1 /* edit for performance measurements */ |
| + | |
| static CURLcode test_unit1627(const char *arg) | |
| { | |
| UNITTEST_BEGIN_SIMPLE | |
| - | size_t i, j; |
| + | size_t i = 0, j = 0, a; |
| /* existing schemes in different cases */ | |
| static const char * const okay[] = { | |
| /* all upper */ | |
| @@ -48,9 +50,19 @@ static CURLcode test_unit1627(const char *arg) | |
| "imAP", "imaPS", "LDap", "LDAps", "mQTT", "mqtTS", "pOP3", "pOP3s", | |
| "RtsP", "ScP", "SFtP", "Smb", "smBS", "sMTP", "SMTPs", | |
| "TELNEt", "tFTP", "Ws", "wSS", | |
| + | |
| + | "SOCKS", "SOCKS4", "SOCKS5", "SOCKS4A", "SOCKS5H", |
| + | "socks", "socks4", "socks5", "socks4a", "socks5h", |
| + | "Socks", "sOcks4", "soCks5", "socKs4a", "sockS5h", |
| }; | |
| /* non-existing schemes */ | |
| static const char * const notokay[] = { | |
| + | "a", "A", "ht", "tt", "tt", "p+", "TPP", "PPS", "TSP", |
| + | "HER", "1CT", "AbG", "LQp", "rtW", "PkY", "xZq", "LmO", |
| + | "hyT", "wQA", "dfG", "BvC", "iuY", "ewQ", "dfG", "Jkl", |
| + | "NbV", "cXz", "OiU", "SrE", "QaS", "ghJ", "LmN", "VcX", "PoI", |
| + | "YtR", "WqA", "DfG", "JkL", "XcV", "NmM", "WeR", "YuI", "PaS", |
| + | |
| "a", "A", "htt", "ttp", "httt", "http+", "HTTPP", "HTTPPS", "HTTSP", | |
| "GROPHER", "D1CT", "AbG", "zLQp", "mNrtW", "PkY", "bVcxZq", "LmO", | |
| "iUhyT", "rEwQA", "xSdfG", "nBvC", "pOiuY", "tRewQ", "aSdfG", "hJkl", | |
| @@ -64,37 +76,84 @@ static CURLcode test_unit1627(const char *arg) | |
| "AsDf", "GhJk", "LzXc", "VbNm", "qWeR", "tYuI", "oPaS", "dFgH", "jKlZ", | |
| "xCvB", "nMqW", "eRtY", "uIoP", "aSdF", "gHjK", "lZxC", "vBnM", "QwEr", | |
| "TyUi", "OpAs", "DfGh", "JkLz", "XcVb", "NmqW", "ErTy", "UiOp", "AsDf", | |
| - | "GhJk", "LzXc", "VbNm" |
| + | "GhJk", "LzXc", "VbNm", |
| + | |
| + | "aa", "Aa", "htta", "ttpa", "httta", "http+a", "HTTPPa", "HTTPPSa", |
| + | "HTTSPa", "GROPHERa", "D1CTa", "AbGa", "zLQpa", "mNrtWa", "PkYa", |
| + | "bVcxZqa", "LmOa", "iUhyTa", "rEwQAa", "xSdfGa", "nBvCa", "pOiuYa", |
| + | "tRewQa", "aSdfGa", "hJkla", "mNbVa", "cXza", "pOiUa", "yTrEa", "wQaSa", |
| + | "dFghJa", "kLmNa", "bVcXa", "zPoIa", "uYtRa", "eWqAa", "sDfGa", "hJkLa", |
| + | "zXcVa", "bNmMa", "qWeRa", "tYuIa", "oPaSa", "dFgHa", "jKlZa", "xCvBa", |
| + | "nMqWa", "eRtYa", "uIoPa", "aSdFa", "gHjKa", "lZxCa", "vBnMa", "QwEra", |
| + | "TyUia", "OpAsa", "DfGha", "JkLza", "XcVba", "NmqWa", "ErTya", "UiOpa", |
| + | "AsDfa", "GhJka", "LzXca", "VbNma", "qweRa", "tyuIa", "opaDa", "fghJa", |
| + | "klzxa", "cvbna", "mQWa", "ErTya", "UiOpa", "AsDfa", "GhJka", "LzXca", |
| + | "VbNma", "QwEra", "TyUia", "OpAsa", "DfGha", "JkLza", "XcVba", "NmqWa", |
| + | "ErTya", "UiOpa", "AsDfa", "GhJka", "LzXca", "VbNma", "qWeRa", "tYuIa", |
| + | "oPaSa", "dFgHa", "jKlZa", "xCvBa", "nMqWa", "eRtYa", "uIoPa", "aSdFa", |
| + | "gHjKa", "lZxCa", "vBnMa", "QwEra", "TyUia", "OpAsa", "DfGha", "JkLza", |
| + | "XcVba", "NmqWa", "ErTya", "UiOpa", "AsDfa", "GhJka", "LzXca", "VbNma", |
| + | |
| + | "aab", "Aab", "httab", "ttpab", "htttab", "http+ab", "HTTPPab", "HTTPPSab", |
| + | "HTTSPab", "GROPHERab", "D1CTab", "AbGab", "zLQpab", "mNrtWab", "PkYab", |
| + | "bVcxZqab", "LmOab", "iUhyTab", "rEwQAab", "xSdfGab", "nBvCab", "pOiuYab", |
| + | "tRewQab", "aSdfGab", "hJklab", "mNbVab", "cXzab", "pOiUab", "yTrEab", |
| + | "wQaSab", "dFghJab", "kLmNab", "bVcXab", "zPoIab", "uYtRab", "eWqAab", |
| + | "sDfGab", "hJkLab", "zXcVab", "bNmMab", "qWeRab", "tYuIab", "oPaSab", |
| + | "dFgHab", "jKlZab", "xCvBab", "nMqWab", "eRtYab", "uIoPab", "aSdFab", |
| + | "gHjKab", "lZxCab", "vBnMab", "QwErab", "TyUiab", "OpAsab", "DfGhab", |
| + | "JkLzab", "XcVbab", "NmqWab", "ErTyab", "UiOpab", "AsDfab", "GhJkab", |
| + | "LzXcab", "VbNmab", "qweRab", "tyuIab", "opaDab", "fghJab", "klzxab", |
| + | "cvbnab", "mQWab", "ErTyab", "UiOpab", "AsDfab", "GhJkab", "LzXcab", |
| + | "VbNmab", "QwErab", "TyUiab", "OpAsab", "DfGhab", "JkLzab", "XcVbab", |
| + | "NmqWab", "ErTyab", "UiOpab", "AsDfab", "GhJkab", "LzXcab", "VbNmab", |
| + | "qWeRab", "tYuIab", "oPaSab", "dFgHab", "jKlZab", "xCvBab", "nMqWab", |
| + | "eRtYab", "uIoPab", "aSdFab", "gHjKab", "lZxCab", "vBnMab", "QwErab", |
| + | "TyUiab", "OpAsab", "DfGhab", "JkLzab", "XcVbab", "NmqWab", "ErTyab", |
| + | "UiOpab", "AsDfab", "GhJkab", "LzXcab", "VbNmab", |
| + | |
| + | "dictt", "filee", "ftpp", "ftpss", "gopherr", "gopherss", "httpp", |
| + | "httpss", "imapp", "imapss", "ldapp", "ldapss", "mqttt", "mqttss", |
| + | "pop33", "pop3ss", "rtspp", "scpp", "sftpp", "smbb", "smbss", "smtpp", |
| + | "smtpss", "telnett", "tftpp", "wsw", "wsss", |
| + | |
| + | "DIC", "FIL", "FT", "TPS", "GOPHE", "OPHER", "HTT", "TTPS", |
| + | "IMA", "APS", "LDA", "APS", "MQT", "TTS", "POP", "P3S", |
| + | "RTS", "SC", "SFT", "SM", "BS", "SMT", "TPS", |
| + | "TELNE", "TFT", "W", "S", |
| }; | |
| - | for(i = 0; i < CURL_ARRAYSIZE(okay); i++) { |
| - | char buffer[32]; |
| - | const struct Curl_scheme *get = Curl_get_scheme(okay[i]); |
| - | if(get) { |
| - | /* verify that we got the correct scheme */ |
| - | if(!curl_strequal(get->name, okay[i])) |
| - | get = NULL; |
| - | } |
| - | if(!get) { |
| - | curl_mprintf("Input: %s, expected okay\n", okay[i]); |
| - | break; |
| - | } |
| - | Curl_strntolower(buffer, okay[i], strlen(okay[i])); |
| - | buffer[strlen(okay[i])] = 0; |
| - | if(strcmp(buffer, get->name)) { |
| - | curl_mprintf("Input: %s is not lowercase: %s\n", buffer, get->name); |
| - | break; |
| + | for(a = 0 ; a < ITERATIONS1627; a++) { |
| + | |
| + | for(i = 0; i < CURL_ARRAYSIZE(okay); i++) { |
| + | char buffer[32]; |
| + | const struct Curl_scheme *get = Curl_get_scheme(okay[i]); |
| + | if(get) { |
| + | /* verify that we got the correct scheme */ |
| + | if(!curl_strequal(get->name, okay[i])) |
| + | get = NULL; |
| + | } |
| + | if(!get) { |
| + | curl_mprintf("Input: %s, expected okay\n", okay[i]); |
| + | break; |
| + | } |
| + | Curl_strntolower(buffer, okay[i], strlen(okay[i])); |
| + | buffer[strlen(okay[i])] = 0; |
| + | if(strcmp(buffer, get->name)) { |
| + | curl_mprintf("Input: %s is not lowercase: %s\n", buffer, get->name); |
| + | break; |
| + | } |
| } | |
| - | } |
| - | for(j = 0; j < CURL_ARRAYSIZE(notokay); j++) { |
| - | const struct Curl_scheme *get = Curl_get_scheme(notokay[j]); |
| - | if(get) { |
| - | curl_mprintf("Input: %s, expected not okay\n", notokay[j]); |
| - | break; |
| + | for(j = 0; j < CURL_ARRAYSIZE(notokay); j++) { |
| + | const struct Curl_scheme *get = Curl_get_scheme(notokay[j]); |
| + | if(get) { |
| + | curl_mprintf("Input: %s, expected not okay\n", notokay[j]); |
| + | break; |
| + | } |
| } | |
| } | |
| - | curl_mprintf("%zu invokes\n", i + j); |
| + | curl_mprintf("%zu invokes\n", (i + j) * ITERATIONS1627); |
| if(i != CURL_ARRAYSIZE(okay) || | |
| j != CURL_ARRAYSIZE(notokay)) | |