[gnome-photos/wip/rishi/manager-model: 4/8] base-manager: Avoid O(n) logic



commit ccfc17b67070f9abed2846d3146ada9f196dba7e
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Nov 5 13:18:25 2016 +0100

    base-manager: Avoid O(n) logic
    
    Calculating the size of a GHashTable is a O(1) operation. There is no
    need to iterate over the list of values for that.

 src/photos-base-manager.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index dd71022..2cca3a8 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -374,7 +374,7 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
   priv = photos_base_manager_get_instance_private (self);
 
   values = g_hash_table_get_values (priv->objects);
-  length = g_list_length (values);
+  length = photos_base_manager_get_objects_count (self);
   strv = (gchar **) g_malloc0_n (length + 1, sizeof (gchar *));
 
   for (i = 0, l = values; l != NULL; l = l->next)


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