cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] rawstr: Speed up Curl_raw_toupper by 40%

From: Tim Ruehsen <tim.ruehsen_at_gmx.de>
Date: Mon, 02 Nov 2015 16:39:55 +0100

Hi Lauri,

your code wouldn't work with non-continuous character sets, like EBCDIC.

Did you turn on optimization when compiling curl/libcurl ? Any half-way modern
compiler should translate the current code into a lookup table or code like
yours.

Another option would be to check for a continuous character set within
configure.ac and provide two code paths.

Tim

On Monday 02 November 2015 17:09:45 Lauri Kasanen wrote:
> 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>
> ---
> lib/rawstr.c | 57 +++------------------------------------------------------
> 1 file changed, 3 insertions(+), 54 deletions(-)
>
> diff --git a/lib/rawstr.c b/lib/rawstr.c
> index e27dac4..6990337 100644
> --- a/lib/rawstr.c
> +++ b/lib/rawstr.c
> @@ -28,60 +28,9 @@
> its behavior is altered by the current locale. */
> char Curl_raw_toupper(char in)
> {
> - switch (in) {
> - case 'a':
> - return 'A';
> - case 'b':
> - return 'B';
> - case 'c':
> - return 'C';
> - case 'd':
> - return 'D';
> - case 'e':
> - return 'E';
> - case 'f':
> - return 'F';
> - case 'g':
> - return 'G';
> - case 'h':
> - return 'H';
> - case 'i':
> - return 'I';
> - case 'j':
> - return 'J';
> - case 'k':
> - return 'K';
> - case 'l':
> - return 'L';
> - case 'm':
> - return 'M';
> - case 'n':
> - return 'N';
> - case 'o':
> - return 'O';
> - case 'p':
> - return 'P';
> - case 'q':
> - return 'Q';
> - case 'r':
> - return 'R';
> - case 's':
> - return 'S';
> - case 't':
> - return 'T';
> - case 'u':
> - return 'U';
> - case 'v':
> - return 'V';
> - case 'w':
> - return 'W';
> - case 'x':
> - return 'X';
> - case 'y':
> - return 'Y';
> - case 'z':
> - return 'Z';
> - }
> + if (in >= 'a' && in <= 'z')
> + return 'A' + in - 'a';
> +
> return in;
> }
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-11-02