Optimize utf8_case_conv()
authorJeffrey Stedfast <fejj@gnome.org>
Wed, 27 Apr 2011 00:46:39 +0000 (20:46 -0400)
committerJeffrey Stedfast <fejj@gnome.org>
Wed, 27 Apr 2011 00:46:39 +0000 (20:46 -0400)
Seems like g_utf8_strdown/up expect valid utf8, so it
should be safe for us to use g_utf8_to_ucs4_fast().

eglib/src/gutf8.c

index 67b2cfe2fc78c9e84c2d9a02ffd9bb0903d5fa35..511f42d3d519703e5a8e5739c612b3a5198059f2 100644 (file)
@@ -36,7 +36,7 @@ utf8_case_conv (const gchar *str, gssize len, gboolean upper)
        glong i, ulen;
        gchar *utf8;
        
-       ustr = g_utf8_to_ucs4 (str, (glong) len, NULL, &ulen, NULL);
+       ustr = g_utf8_to_ucs4_fast (str, (glong) len, &ulen);
        for (i = 0; i < ulen; i++)
                ustr[i] = upper ? g_unichar_toupper (ustr[i]) : g_unichar_tolower (ustr[i]);
        utf8 = g_ucs4_to_utf8 (ustr, ulen, NULL, NULL, NULL);