[gnome-photos/wip/rishi/collection: 7/40] item-manager: Avoid a goto



commit 9d334df7b823881a68187d21a7524af3e35a8003
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 46c0db10..a3041a4e 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -1071,24 +1071,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]