[gnome-photos/wip/rishi/collection: 3/35] item-manager: Avoid a goto



commit dccc70575ab1e064763abc8f299dba4095da641f
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jan 24 12:27:53 2018 +0100

    item-manager: Avoid a goto
    
    The current structure of the code was driven by the lack of
    g_auto*-like RAII.

 src/photos-item-manager.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 39de8900..20d13fa6 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -1045,24 +1045,23 @@ photos_item_manager_create_item (PhotosItemManager *self, TrackerSparqlCursor *c
   g_return_val_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor), NULL);
 
   identifier = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_IDENTIFIER, NULL));
-  if (identifier == NULL)
-    goto final;
-
-  split_identifier = g_strsplit (identifier, ":", 4);
-
-  if (photos_item_manager_cursor_is_collection (cursor))
-    {
-      /* Its a collection. */
-      extension_name = split_identifier[2];
-    }
-  else
+  if (identifier != NULL)
     {
-      /* Its a normal photo item. */
-      if (g_strv_length (split_identifier) > 1)
-        extension_name = split_identifier[0];
+      split_identifier = g_strsplit (identifier, ":", 4);
+
+      if (photos_item_manager_cursor_is_collection (cursor))
+        {
+          /* Its a collection. */
+          extension_name = split_identifier[2];
+        }
+      else
+        {
+          /* Its a normal photo item. */
+          if (g_strv_length (split_identifier) > 1)
+            extension_name = split_identifier[0];
+        }
     }
 
- final:
   extension = g_io_extension_point_get_extension_by_name (self->extension_point, extension_name);
   if (G_UNLIKELY (extension == NULL))
     {


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