diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 23e4c46e1..5e7b509d9 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,10 +1,17 @@ +2002-03-13 Alexander Larsson + + * 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 * gobject/gclosure.c * gobject/gobject.c * gobject/gsignal.c: fixed cast problems with function pointer to avoid warnings (with forte compiler) (#73898) - 2002-03-05 Sven Neumann * gvaluetransform.c (g_value_transforms_init): don't try to diff --git a/gobject/gparam.c b/gobject/gparam.c index 0a1d3f81b..3bcdc376f 100644 --- a/gobject/gparam.c +++ b/gobject/gparam.c @@ -257,6 +257,21 @@ g_param_spec_get_blurb (GParamSpec *pspec) 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 g_param_spec_internal (GType param_type, const gchar *name, @@ -272,7 +287,7 @@ g_param_spec_internal (GType param_type, pspec = (gpointer) g_type_create_instance (param_type); 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->_blurb = g_strdup (blurb); 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.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) do {