curl-library
[PATCH v2] rawstr: Speed up Curl_raw_toupper by 40%
From: Lauri Kasanen <cand_at_gmx.com>
Date: Mon, 2 Nov 2015 18:20:06 +0200
Date: Mon, 2 Nov 2015 18:20:06 +0200
Rationale: when starting up a curl-using app, all cookies from the jar are
checked against each other. This was causing a two-second startup delay in
the Fifth browser.
All tests pass.
Signed-off-by: Lauri Kasanen <cand_at_gmx.com>
--- v2: Guards as suggested by Tim. The speedup still correctly happens, tested gcc 4.2.0 and 5.2.0, both at -O3 -march=native. lib/rawstr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/rawstr.c b/lib/rawstr.c index e27dac4..752195c 100644 --- a/lib/rawstr.c +++ b/lib/rawstr.c @@ -28,6 +28,10 @@ its behavior is altered by the current locale. */ char Curl_raw_toupper(char in) { +#if ('z' - 'a' == 25) && ('Z' - 'A' == 25) + if (in >= 'a' && in <= 'z') + return 'A' + in - 'a'; +#else switch (in) { case 'a': return 'A'; @@ -82,6 +86,8 @@ char Curl_raw_toupper(char in) case 'z': return 'Z'; } +#endif + return in; } -- 2.6.2 ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2015-11-02