mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-28 10:30:03 +01:00
gdatalist: rework g_datalist_clear() to return early
g_datalist_unlock() is probably faster than g_datalist_unlock_and_set(). Move the "if (data)" check (that we anyway had) earlier, so we can call g_datalist_unlock() and return early.
This commit is contained in:
parent
759ebf3663
commit
dbae6b3484
@ -234,18 +234,22 @@ g_datalist_clear (GData **datalist)
|
||||
g_return_if_fail (datalist != NULL);
|
||||
|
||||
data = g_datalist_lock_and_get (datalist);
|
||||
|
||||
if (!data)
|
||||
{
|
||||
g_datalist_unlock (datalist);
|
||||
return;
|
||||
}
|
||||
|
||||
g_datalist_unlock_and_set (datalist, NULL);
|
||||
|
||||
if (data)
|
||||
for (i = 0; i < data->len; i++)
|
||||
{
|
||||
for (i = 0; i < data->len; i++)
|
||||
{
|
||||
if (data->data[i].data && data->data[i].destroy)
|
||||
data->data[i].destroy (data->data[i].data);
|
||||
}
|
||||
|
||||
g_free (data);
|
||||
if (data->data[i].data && data->data[i].destroy)
|
||||
data->data[i].destroy (data->data[i].data);
|
||||
}
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
/* HOLDS: g_dataset_global_lock */
|
||||
|
Loading…
x
Reference in New Issue
Block a user