Speed up g_dataset_id_dup_data

This code is used in the property notification path, so it
better be fast. This commit removes a g_return_if_fail check and
treats the common case of just a single data element better.
This commit is contained in:
Matthias Clasen 2015-09-12 01:47:13 -04:00
parent 59df5440f3
commit c90f283be3

View File

@ -849,16 +849,14 @@ g_datalist_id_dup_data (GData **datalist,
GData *d; GData *d;
GDataElt *data, *data_end; GDataElt *data, *data_end;
g_return_val_if_fail (datalist != NULL, NULL);
g_datalist_lock (datalist); g_datalist_lock (datalist);
d = G_DATALIST_GET_POINTER (datalist); d = G_DATALIST_GET_POINTER (datalist);
if (d) if (d)
{ {
data = d->data; data = d->data;
data_end = data + d->len - 1; data_end = data + d->len;
while (data <= data_end) do
{ {
if (data->key == key_id) if (data->key == key_id)
{ {
@ -867,6 +865,7 @@ g_datalist_id_dup_data (GData **datalist,
} }
data++; data++;
} }
while (data < data_end);
} }
if (dup_func) if (dup_func)