summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-02-27 06:46:08 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-02-27 06:46:08 +0000
commitb501a17c8b12844085419cf818b572de4bce0900 (patch)
tree6bacbcd5458de188bcced0d04ca31d812a7250f0
parent8875974d1824f14f19d67a421440cc2550a4b408 (diff)
downloadgdk-pixbuf-b501a17c8b12844085419cf818b572de4bce0900.tar.gz
Add a configuration option --with-native-locale, that greatly speeds up
Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com> * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a configuration option --with-native-locale, that greatly speeds up wide-character/multibyte conversions by dropping the indirection through Xlib's property-conversion functions. Off by default due to lack of testing for portability, but it should, in general be a more correct way of doing things, and should also remove much of the speed hit that the recent change to the handling of 8-bit fonts may have introduced.
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.pre-2-011
-rw-r--r--ChangeLog.pre-2-1011
-rw-r--r--ChangeLog.pre-2-211
-rw-r--r--ChangeLog.pre-2-411
-rw-r--r--ChangeLog.pre-2-611
-rw-r--r--ChangeLog.pre-2-811
-rw-r--r--INSTALL12
-rw-r--r--acconfig.h4
-rw-r--r--configure.in34
-rw-r--r--gdk/gdkfont.c49
-rw-r--r--gdk/gdkim.c48
12 files changed, 209 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 90c7070f8..5e821b8dc 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,14 @@
+Tue Feb 27 01:29:34 2001 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in acconfig.h gdk/gdkfont.c gdk/gdkim.c INSTALL: Add a
+ configuration option --with-native-locale, that greatly speeds up
+ wide-character/multibyte conversions by dropping the indirection
+ through Xlib's property-conversion functions. Off by default due
+ to lack of testing for portability, but it should, in general be a
+ more correct way of doing things, and should also remove much of
+ the speed hit that the recent change to the handling of 8-bit
+ fonts may have introduced.
+
Mon Feb 26 16:34:33 2001 Owen Taylor <otaylor@redhat.com>
* README: Update to describe submitting patches
diff --git a/INSTALL b/INSTALL
index 4e5247005..7116f3f87 100644
--- a/INSTALL
+++ b/INSTALL
@@ -72,6 +72,18 @@ variables. If you will be using multiple locales with GTK,
specify the one for which your operating system has the worst
support for the --with-locale option.
+* --with-native-locale=[yes/no] Use native locale support
+
+If set, GTK+ will use your C library's native locale support,
+instead of making conversions between wide characters and
+multibyte-strings by going through Xlib's property-conversion
+functions. Specifying this flag can speed up some operations
+involving text by between 5 and 20 times.
+
+This defaults to no, because it has not extensively been
+tested for portability, but should be safe on most modern
+systems.
+
Options can be given to the compiler and linker by setting
environment variables before running configure. A few of the more
diff --git a/acconfig.h b/acconfig.h
index 2d4406fa7..ad3a3324f 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -36,6 +36,10 @@
/* Define to use X11R6 additions to XIM */
#undef USE_X11R6_XIM
+/* Define if we should use mbstowcs and friends directly
+ */
+#undef USE_NATIVE_LOCALE
+
#undef XINPUT_NONE
#undef XINPUT_GXI
#undef XINPUT_XFREE
diff --git a/configure.in b/configure.in
index 4647ad647..92005fa4a 100644
--- a/configure.in
+++ b/configure.in
@@ -99,6 +99,7 @@ AC_ARG_ENABLE(rebuilds, [ --disable-rebuilds disable all source autogenera
AC_ARG_WITH(locale, [ --with-locale=LOCALE locale name you want to use ])
AC_ARG_WITH(xinput, [ --with-xinput=[no/gxi/xfree] support XInput ])
+AC_ARG_WITH(native_locale, [ --with-native-locale=[yes/no] Use native locale support [default=no]],,with_native_locale=no)
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
@@ -437,8 +438,41 @@ need_x_locale=yes,
need_x_locale=no)
AC_MSG_RESULT($need_x_locale)
+use_native_locale=no
if test $need_x_locale = yes; then
GTK_LOCALE_FLAGS="-DX_LOCALE"
+else
+ if test x$with_native_locale = xyes ; then
+ AC_MSG_CHECKING(functioning locale support)
+
+ AC_TRY_COMPILE([#include <stdlib.h>],[
+ char c;
+ if (MB_CUR_MAX == 1) {
+ wctomb(&c, 42);
+ }
+ ],use_native_locale=yes,)
+
+ AC_MSG_RESULT($use_native_locale)
+ fi
+fi
+
+if test x$use_native_locale = xyes ; then
+ AC_MSG_CHECKING(if sizeof(wchar_t) == 4)
+
+ AC_TRY_RUN([
+ #include <stdlib.h>
+
+ int
+ main ()
+ {
+ return (sizeof(wchar_t) == 4) ? 0 : 1;
+ }],
+ ,use_native_locale=no,:)
+ AC_MSG_RESULT($use_native_locale)
+fi
+
+if test $use_native_locale = yes ; then
+ AC_DEFINE(USE_NATIVE_LOCALE)
fi
# Checks for header files.
diff --git a/gdk/gdkfont.c b/gdk/gdkfont.c
index 4acc2ce0a..ec9dd563d 100644
--- a/gdk/gdkfont.c
+++ b/gdk/gdkfont.c
@@ -29,9 +29,24 @@
#include "gdk.h"
#include "gdkprivate.h"
+#if HAVE_CONFIG_H
+# include <config.h>
+# if STDC_HEADERS
+# include <string.h>
+# endif
+#endif
+
+#ifdef USE_NATIVE_LOCALE
+#include <stdlib.h>
+#endif
+
static GHashTable *font_name_hash = NULL;
static GHashTable *fontset_name_hash = NULL;
+#define FONT_XFONT(private) ((XFontStruct *)(private)->xfont)
+#define FONT_IS_8BIT(private) ((FONT_XFONT(private)->min_byte1 == 0) && \
+ (FONT_XFONT(private)->max_byte1 == 0))
+
static void
gdk_font_hash_insert (GdkFontType type, GdkFont *font, const gchar *font_name)
{
@@ -482,18 +497,28 @@ gdk_char_width_wc (GdkFont *font,
switch (font->type)
{
case GDK_FONT_FONT:
- {
- gchar *glyphs;
- int glyphs_len;
-
- _gdk_font_wc_to_glyphs (font, &character, 1, &glyphs, &glyphs_len);
-
- width = gdk_text_width (font, glyphs, glyphs_len);
-
- g_free (glyphs);
+#ifdef USE_NATIVE_LOCALE
+ if (MB_CUR_MAX == 1 && FONT_IS_8BIT(private))
+ {
+ char c;
+ g_assert (wctomb(&c,character) == 1);
- break;
- }
+ return gdk_char_width (font, c);
+ }
+ else
+#endif /* USE_NATIVE_LOCALE */
+ {
+ gchar *glyphs;
+ int glyphs_len;
+
+ _gdk_font_wc_to_glyphs (font, &character, 1, &glyphs, &glyphs_len);
+
+ width = gdk_text_width (font, glyphs, glyphs_len);
+
+ g_free (glyphs);
+
+ break;
+ }
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
{
@@ -811,7 +836,7 @@ _gdk_font_wc_to_glyphs (GdkFont *font,
xfont = (XFontStruct *) font_private->xfont;
- if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
+ if (FONT_IS_8BIT (font_private))
{
/* 8-bit font, assume that we are in a 8-bit locale,
* and convert to bytes using wcstombs.
diff --git a/gdk/gdkim.c b/gdk/gdkim.c
index 90b06c470..cd830ea57 100644
--- a/gdk/gdkim.c
+++ b/gdk/gdkim.c
@@ -37,6 +37,9 @@
# endif
#endif
+#ifdef USE_NATIVE_LOCALE
+#include <stdlib.h>
+#endif
/* If this variable is FALSE, it indicates that we should
* avoid trying to use multibyte conversion functions and
@@ -1480,12 +1483,46 @@ gdk_ic_get_events (GdkIC *ic)
#endif /* USE_XIM */
/*
- * gdk_wcstombs
+ * gdk_wcstombs_len
*
* Returns a multi-byte string converted from the specified array
* of wide characters. The string is newly allocated. The array of
* wide characters is nul-terminated, if len < 0
*/
+
+#ifdef USE_NATIVE_LOCALE
+gchar *
+_gdk_wcstombs_len (const GdkWChar *src,
+ int src_len)
+{
+ int len = 0;
+ int i;
+ char *result;
+ char buf[16];
+ char *p;
+
+ if (MB_CUR_MAX <= 16)
+ p = buf;
+ else
+ p = g_malloc (MB_CUR_MAX); /* Presumably never hit */
+
+ wctomb (NULL, 0);
+
+ for (i=0; (src_len < 0 || i < src_len) && src[i]; i++)
+ len += wctomb (p, src[i]);
+
+ result = g_malloc (len + 1);
+
+ wcstombs (result, (wchar_t *)src, len);
+ result[len] = '\0';
+
+ if (p != buf)
+ g_free (p);
+
+ return result;
+}
+#else /* !USE_NATIVE_LOCALE */
+
gchar *
_gdk_wcstombs_len (const GdkWChar *src,
int len)
@@ -1554,6 +1591,7 @@ _gdk_wcstombs_len (const GdkWChar *src,
return mbstr;
}
+#endif /* !USE_NATIVE_LOCALE */
/*
* gdk_wcstombs
@@ -1579,6 +1617,9 @@ gdk_wcstombs (const GdkWChar *src)
gint
gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
{
+#ifdef USE_NATIVE_LOCALE
+ return mbstowcs ((wchar_t *)dest, src, dest_max);
+#else
if (gdk_use_mb)
{
XTextProperty tpr;
@@ -1611,10 +1652,11 @@ gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
else
{
gint i;
-
+
for (i=0; i<dest_max && src[i]; i++)
dest[i] = (guchar)src[i];
-
+
return i;
}
+#endif
}