From 173ec86fc05666690909a2ffe4721217fb3ceb51 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Oct 2004 02:10:45 +0000 Subject: r2902: make toupper_w() and tolower_w() slightly faster by putting the most common conditions first (This used to be commit 878f6b565f4e80eefbb08f44551b3b4f647d7aa7) --- source4/lib/util_unistr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4') diff --git a/source4/lib/util_unistr.c b/source4/lib/util_unistr.c index 672c7cd2c8..7d10b92c43 100644 --- a/source4/lib/util_unistr.c +++ b/source4/lib/util_unistr.c @@ -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); -- cgit