Function to canonicalize parameter names. Faster than using g_strcanon().

2002-03-13  Alexander Larsson  <alla@lysator.liu.se>

	* gparam.c (canonalize_key):
	Function to canonicalize parameter names. Faster than
	using g_strcanon().
	(g_param_spec_internal, param_spec_ht_lookup):
	Use canonalize_key.
This commit is contained in:
Alexander Larsson 2002-03-14 01:41:40 +00:00 committed by Alexander Larsson
parent 738c1cfd6b
commit f318cdcacb
2 changed files with 25 additions and 3 deletions

View File

@ -1,10 +1,17 @@
2002-03-13 Alexander Larsson <alla@lysator.liu.se>
* gparam.c (canonalize_key):
Function to canonicalize parameter names. Faster than
using g_strcanon().
(g_param_spec_internal, param_spec_ht_lookup):
Use canonalize_key.
2002-03-13 Erwann Chenede <erwann.chenede@sun.com> 2002-03-13 Erwann Chenede <erwann.chenede@sun.com>
* gobject/gclosure.c * gobject/gclosure.c
* gobject/gobject.c * gobject/gobject.c
* gobject/gsignal.c: fixed cast problems with function pointer * gobject/gsignal.c: fixed cast problems with function pointer
to avoid warnings (with forte compiler) (#73898) to avoid warnings (with forte compiler) (#73898)
2002-03-05 Sven Neumann <sven@gimp.org> 2002-03-05 Sven Neumann <sven@gimp.org>
* gvaluetransform.c (g_value_transforms_init): don't try to * gvaluetransform.c (g_value_transforms_init): don't try to

View File

@ -257,6 +257,21 @@ g_param_spec_get_blurb (GParamSpec *pspec)
return pspec->_blurb; return pspec->_blurb;
} }
static void
canonalize_key(gchar *key)
{
gchar *p, c;
for (p = key; (c = *p) != 0; p++)
{
if (c != '-' &&
(c < '0' || c > '9') &&
(c < 'A' || c > 'Z') &&
(c < 'a' || c > 'z'))
*p = '-';
}
}
gpointer gpointer
g_param_spec_internal (GType param_type, g_param_spec_internal (GType param_type,
const gchar *name, const gchar *name,
@ -272,7 +287,7 @@ g_param_spec_internal (GType param_type,
pspec = (gpointer) g_type_create_instance (param_type); pspec = (gpointer) g_type_create_instance (param_type);
pspec->name = g_strdup (name); pspec->name = g_strdup (name);
g_strcanon (pspec->name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-'); canonalize_key (pspec->name);
pspec->_nick = g_strdup (nick); pspec->_nick = g_strdup (nick);
pspec->_blurb = g_strdup (blurb); pspec->_blurb = g_strdup (blurb);
pspec->flags = (flags & G_PARAM_USER_MASK) | (flags & G_PARAM_MASK); pspec->flags = (flags & G_PARAM_USER_MASK) | (flags & G_PARAM_MASK);
@ -650,7 +665,7 @@ param_spec_ht_lookup (GHashTable *hash_table,
key.name = g_strdup (param_name); key.name = g_strdup (param_name);
key.owner_type = owner_type; key.owner_type = owner_type;
g_strcanon (key.name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-'); canonalize_key (key.name);
if (walk_ancestors) if (walk_ancestors)
do do
{ {