GParamSpec: intern property names

Make it so that the ->name property on all GParamSpec objects is an
interned string.

https://bugzilla.gnome.org/show_bug.cgi?id=654627
This commit is contained in:
Ryan Lortie 2011-07-14 18:08:25 +02:00
parent 7041b701dd
commit d6c30e1766
2 changed files with 13 additions and 7 deletions

View File

@ -173,9 +173,6 @@ g_param_spec_finalize (GParamSpec *pspec)
{
g_datalist_clear (&pspec->qdata);
if (!(pspec->flags & G_PARAM_STATIC_NAME))
g_free (pspec->name);
if (!(pspec->flags & G_PARAM_STATIC_NICK))
g_free (pspec->_nick);
@ -275,6 +272,9 @@ g_param_spec_ref_sink (GParamSpec *pspec)
*
* Get the name of a #GParamSpec.
*
* The name is always an "interned" string (as per g_intern_string()).
* This allows for pointer-value comparisons.
*
* Returns: the name of @pspec.
*/
const gchar *
@ -428,9 +428,15 @@ g_param_spec_internal (GType param_type,
}
else
{
pspec->name = g_strdup (name);
canonicalize_key (pspec->name);
g_intern_string (pspec->name);
if (is_canonical (name))
pspec->name = (gchar *) g_intern_string (name);
else
{
gchar *tmp = g_strdup (name);
canonicalize_key (tmp);
pspec->name = (gchar *) g_intern_string (tmp);
g_free (tmp);
}
}
if (flags & G_PARAM_STATIC_NICK)

View File

@ -193,7 +193,7 @@ typedef struct _GParamSpecPool GParamSpecPool;
/**
* GParamSpec:
* @g_type_instance: private #GTypeInstance portion
* @name: name of this parameter
* @name: name of this parameter: always an interned string
* @flags: #GParamFlags flags for this parameter
* @value_type: the #GValue type for this parameter
* @owner_type: #GType type that uses (introduces) this parameter