mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
param: Avoid strchrs
Using prefixed property names like GtkWidget::visible is very deprectated and basically never done. So avoid paying the strchr cost before doing the first lookup.
This commit is contained in:
parent
91dafa85fc
commit
51215bf7b8
@ -1094,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);
|
||||||
@ -1141,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);
|
||||||
|
Loading…
Reference in New Issue
Block a user