Commit d6c30e17 authored by Allison Karlitskaya's avatar Allison Karlitskaya
Browse files

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
parent 7041b701
......@@ -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)
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment