cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] rawstr: Speed up Curl_raw_toupper by 40%

From: Lauri Kasanen <cand_at_gmx.com>
Date: Mon, 2 Nov 2015 17:09:45 +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>

---
 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;
 }
 
-- 
2.6.2
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-11-02