[glib] Speed up g_dataset_id_dup_data



commit c90f283be33bffde48c244e0478b63fd6798fbcf
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Sep 12 01:47:13 2015 -0400

    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.

 glib/gdataset.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/glib/gdataset.c b/glib/gdataset.c
index 4c02d36..71aaa8e 100644
--- a/glib/gdataset.c
+++ b/glib/gdataset.c
@@ -849,16 +849,14 @@ g_datalist_id_dup_data (GData          **datalist,
   GData *d;
   GDataElt *data, *data_end;
 
-  g_return_val_if_fail (datalist != NULL, NULL);
-
   g_datalist_lock (datalist);
 
   d = G_DATALIST_GET_POINTER (datalist);
   if (d)
     {
       data = d->data;
-      data_end = data + d->len - 1;
-      while (data <= data_end)
+      data_end = data + d->len;
+      do
         {
           if (data->key == key_id)
             {
@@ -867,6 +865,7 @@ g_datalist_id_dup_data (GData          **datalist,
             }
           data++;
         }
+      while (data < data_end);
     }
 
   if (dup_func)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]