[gimp] app: don't use g_list_length() to check if a list is empty



commit 11239c4b1731a3f4cb071d1c51a0af95a206bec8
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 9 00:27:53 2011 +0200

    app: don't use g_list_length() to check if a list is empty

 app/display/gimpsinglewindowstrategy.c |    2 +-
 app/widgets/gimpdockwindow.c           |    2 +-
 app/widgets/gimppanedbox.c             |   21 ++++++++++-----------
 app/widgets/gimptoolbox.c              |    2 +-
 4 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/app/display/gimpsinglewindowstrategy.c b/app/display/gimpsinglewindowstrategy.c
index 5201cb3..fa7fd0a 100644
--- a/app/display/gimpsinglewindowstrategy.c
+++ b/app/display/gimpsinglewindowstrategy.c
@@ -82,7 +82,7 @@ gimp_single_window_strategy_create_dockable_dialog (GimpWindowStrategy *strategy
   GtkWidget       *widget  = NULL;
   GimpImageWindow *window;
 
-  g_return_val_if_fail (g_list_length (windows) > 0, NULL);
+  g_return_val_if_fail (windows != NULL, NULL);
 
   /* In single-window mode, there should only be one window... */
   window = GIMP_IMAGE_WINDOW (windows->data);
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index abdfb29..f919785 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -837,7 +837,7 @@ gimp_dock_window_should_add_to_recent (GimpDockWindow *dock_window)
 
   docks = gimp_dock_container_get_docks (GIMP_DOCK_CONTAINER (dock_window));
 
-  if (g_list_length (docks) < 1)
+  if (! docks)
     {
       should_add = FALSE;
     }
diff --git a/app/widgets/gimppanedbox.c b/app/widgets/gimppanedbox.c
index c0aebb9..dfe9801 100644
--- a/app/widgets/gimppanedbox.c
+++ b/app/widgets/gimppanedbox.c
@@ -234,10 +234,9 @@ gimp_paned_box_set_widget_drag_handler (GtkWidget    *widget,
 static gint
 gimp_paned_box_get_drop_area_size (GimpPanedBox *paned_box)
 {
-  gboolean no_widgets     = (g_list_length (paned_box->p->widgets) == 0);
-  gint     drop_area_size = 0;
+  gint drop_area_size = 0;
 
-  if (no_widgets)
+  if (! paned_box->p->widgets)
     {
       GtkAllocation  allocation;
       GtkOrientation orientation;
@@ -340,7 +339,6 @@ gimp_paned_box_drag_motion (GtkWidget      *widget,
   GtkOrientation orientation    = 0;
   gboolean       handle         = FALSE;
   gint           drop_area_size = gimp_paned_box_get_drop_area_size (paned_box);
-  gboolean       no_widgets     = (g_list_length (paned_box->p->widgets) == 0);
 
   if (gimp_paned_box_will_handle_drag (paned_box->p->drag_handler,
                                        widget,
@@ -355,11 +353,6 @@ gimp_paned_box_drag_motion (GtkWidget      *widget,
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  /* If there are no widgets, the drop area is as big as the paned
-   * box
-   */
-  no_widgets = (g_list_length (paned_box->p->widgets) == 0);
-
   /* See if we're at the edge of the dock If there are no dockables,
    * the entire paned box is a drop area
    */
@@ -369,7 +362,10 @@ gimp_paned_box_drag_motion (GtkWidget      *widget,
       dnd_window_y = 0;
       dnd_window_h = allocation.height;
 
-      if (no_widgets)
+      /* If there are no widgets, the drop area is as big as the paned
+       * box
+       */
+      if (! paned_box->p->widgets)
         dnd_window_w = allocation.width;
       else
         dnd_window_w = drop_area_size;
@@ -390,7 +386,10 @@ gimp_paned_box_drag_motion (GtkWidget      *widget,
       dnd_window_x = 0;
       dnd_window_w = allocation.width;
 
-      if (no_widgets)
+      /* If there are no widgets, the drop area is as big as the paned
+       * box
+       */
+      if (! paned_box->p->widgets)
         dnd_window_h = allocation.height;
       else
         dnd_window_h = drop_area_size;
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index e4ad447..e6f03d1 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -583,7 +583,7 @@ gimp_toolbox_book_removed (GimpDock     *dock,
   if (GIMP_DOCK_CLASS (parent_class)->book_removed)
     GIMP_DOCK_CLASS (parent_class)->book_removed (dock, dockbook);
 
-  if (g_list_length (gimp_dock_get_dockbooks (dock)) == 0 &&
+  if (! gimp_dock_get_dockbooks (dock) &&
       ! toolbox->p->in_destruction)
     {
       gimp_dock_invalidate_geometry (dock);



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