r2902: make toupper_w() and tolower_w() slightly faster by putting the most common
authorAndrew Tridgell <tridge@samba.org>
Mon, 11 Oct 2004 02:10:45 +0000 (02:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:46 +0000 (12:59 -0500)
conditions first

source/lib/util_unistr.c

index 672c7cd2c8889041b250fe7af0008618c95036c4..7d10b92c4303a0de37b052433781fb3b4670f623 100644 (file)
@@ -54,16 +54,16 @@ static void load_case_tables(void)
 ********************************************************************/
 codepoint_t toupper_w(codepoint_t val)
 {
-       if (val & 0xFFFF0000) {
-               return val;
-       }
        if (val < 128) {
                return toupper(val);
        }
+       if (upcase_table == (void *)-1) {
+               return val;
+       }
        if (upcase_table == NULL) {
                load_case_tables();
        }
-       if (upcase_table == (void *)-1) {
+       if (val & 0xFFFF0000) {
                return val;
        }
        return SVAL(upcase_table, val*2);
@@ -74,16 +74,16 @@ codepoint_t toupper_w(codepoint_t val)
 ********************************************************************/
 codepoint_t tolower_w(codepoint_t val)
 {
-       if (val & 0xFFFF0000) {
-               return val;
-       }
        if (val < 128) {
                return tolower(val);
        }
+       if (lowcase_table == (void *)-1) {
+               return val;
+       }
        if (lowcase_table == NULL) {
                load_case_tables();
        }
-       if (lowcase_table == (void *)-1) {
+       if (val & 0xFFFF0000) {
                return val;
        }
        return SVAL(lowcase_table, val*2);