mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 04:45:48 +01:00
Merge branch 'param-speedups' into 'main'
param: Avoid strcmps See merge request GNOME/glib!2673
This commit is contained in:
commit
1f42078ace
@ -923,7 +923,8 @@ param_spec_pool_equals (gconstpointer key_spec_1,
|
|||||||
const GParamSpec *key2 = key_spec_2;
|
const GParamSpec *key2 = key_spec_2;
|
||||||
|
|
||||||
return (key1->owner_type == key2->owner_type &&
|
return (key1->owner_type == key2->owner_type &&
|
||||||
strcmp (key1->name, key2->name) == 0);
|
(key1->name == key2->name ||
|
||||||
|
strcmp (key1->name, key2->name) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1093,26 +1094,28 @@ g_param_spec_pool_lookup (GParamSpecPool *pool,
|
|||||||
gboolean walk_ancestors)
|
gboolean walk_ancestors)
|
||||||
{
|
{
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
gchar *delim;
|
|
||||||
|
|
||||||
g_return_val_if_fail (pool != NULL, NULL);
|
g_return_val_if_fail (pool != NULL, NULL);
|
||||||
g_return_val_if_fail (param_name != NULL, NULL);
|
g_return_val_if_fail (param_name != NULL, NULL);
|
||||||
|
|
||||||
g_mutex_lock (&pool->mutex);
|
g_mutex_lock (&pool->mutex);
|
||||||
|
|
||||||
delim = pool->type_prefixing ? strchr (param_name, ':') : NULL;
|
|
||||||
|
|
||||||
/* try quick and away, i.e. without prefix */
|
/* try quick and away, i.e. without prefix */
|
||||||
if (!delim)
|
|
||||||
{
|
|
||||||
pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
|
pspec = param_spec_ht_lookup (pool->hash_table, param_name, owner_type, walk_ancestors);
|
||||||
|
if (pspec)
|
||||||
|
{
|
||||||
g_mutex_unlock (&pool->mutex);
|
g_mutex_unlock (&pool->mutex);
|
||||||
|
|
||||||
return pspec;
|
return pspec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pool->type_prefixing)
|
||||||
|
{
|
||||||
|
char *delim;
|
||||||
|
|
||||||
|
delim = strchr (param_name, ':');
|
||||||
|
|
||||||
/* strip type prefix */
|
/* strip type prefix */
|
||||||
if (pool->type_prefixing && delim[1] == ':')
|
if (delim && delim[1] == ':')
|
||||||
{
|
{
|
||||||
guint l = delim - param_name;
|
guint l = delim - param_name;
|
||||||
gchar stack_buffer[32], *buffer = l < 32 ? stack_buffer : g_new (gchar, l + 1);
|
gchar stack_buffer[32], *buffer = l < 32 ? stack_buffer : g_new (gchar, l + 1);
|
||||||
@ -1140,6 +1143,8 @@ g_param_spec_pool_lookup (GParamSpecPool *pool,
|
|||||||
return pspec;
|
return pspec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* malformed param_name */
|
/* malformed param_name */
|
||||||
|
|
||||||
g_mutex_unlock (&pool->mutex);
|
g_mutex_unlock (&pool->mutex);
|
||||||
|
@ -759,18 +759,6 @@ param_boxed_set_default (GParamSpec *pspec,
|
|||||||
value->data[0].v_pointer = NULL;
|
value->data[0].v_pointer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
param_boxed_validate (GParamSpec *pspec,
|
|
||||||
GValue *value)
|
|
||||||
{
|
|
||||||
/* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
|
|
||||||
guint changed = 0;
|
|
||||||
|
|
||||||
/* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
param_boxed_values_cmp (GParamSpec *pspec,
|
param_boxed_values_cmp (GParamSpec *pspec,
|
||||||
const GValue *value1,
|
const GValue *value1,
|
||||||
@ -1508,7 +1496,7 @@ _g_param_spec_types_init (void)
|
|||||||
G_TYPE_BOXED, /* value_type */
|
G_TYPE_BOXED, /* value_type */
|
||||||
NULL, /* finalize */
|
NULL, /* finalize */
|
||||||
param_boxed_set_default, /* value_set_default */
|
param_boxed_set_default, /* value_set_default */
|
||||||
param_boxed_validate, /* value_validate */
|
NULL, /* value_validate */
|
||||||
param_boxed_values_cmp, /* values_cmp */
|
param_boxed_values_cmp, /* values_cmp */
|
||||||
};
|
};
|
||||||
type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
|
type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user