diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-07-14 18:08:25 +0200 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-07-15 10:23:11 +0200 |
commit | d6c30e1766c975dd79e6f252d73c6c0581b64b01 (patch) | |
tree | 7db8f9a71dd02f6c1f951f25dd2192fee06cde10 /gobject | |
parent | 7041b701dd9fd4f617ca762860447d8fc015a2ab (diff) |
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
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gparam.c | 18 | ||||
-rw-r--r-- | gobject/gparam.h | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/gobject/gparam.c b/gobject/gparam.c index cc845814d..5e9ffe0d3 100644 --- a/gobject/gparam.c +++ b/gobject/gparam.c @@ -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) diff --git a/gobject/gparam.h b/gobject/gparam.h index 5ee41ab91..8f5c04fb9 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -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 |