[gimp] app: don't reverse lists in GimpFilterStack and GimpUndoEditor



commit f1f91ecc2f2b3a920ff6acee6dacb6a7b3d50695
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 3 01:05:49 2016 +0200

    app: don't reverse lists in GimpFilterStack and GimpUndoEditor
    
    GimpList has a tail pointer now and can be traversed in reverse order.

 app/core/gimpfilterstack.c   |   20 +++++---------------
 app/widgets/gimpundoeditor.c |   11 +++++------
 2 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpfilterstack.c b/app/core/gimpfilterstack.c
index 73443ba..50401a1 100644
--- a/app/core/gimpfilterstack.c
+++ b/app/core/gimpfilterstack.c
@@ -180,9 +180,8 @@ GeglNode *
 gimp_filter_stack_get_graph (GimpFilterStack *stack)
 {
   GList    *list;
-  GList    *reverse_list = NULL;
-  GeglNode *first        = NULL;
-  GeglNode *previous     = NULL;
+  GeglNode *first    = NULL;
+  GeglNode *previous = NULL;
   GeglNode *input;
   GeglNode *output;
 
@@ -191,18 +190,11 @@ gimp_filter_stack_get_graph (GimpFilterStack *stack)
   if (stack->graph)
     return stack->graph;
 
-  for (list = GIMP_LIST (stack)->queue->head;
-       list;
-       list = g_list_next (list))
-    {
-      GimpFilter *filter = list->data;
-
-      reverse_list = g_list_prepend (reverse_list, filter);
-    }
-
   stack->graph = gegl_node_new ();
 
-  for (list = reverse_list; list; list = g_list_next (list))
+  for (list = GIMP_LIST (stack)->queue->tail;
+       list;
+       list = g_list_previous (list))
     {
       GimpFilter *filter = list->data;
       GeglNode   *node   = gimp_filter_get_node (filter);
@@ -219,8 +211,6 @@ gimp_filter_stack_get_graph (GimpFilterStack *stack)
       previous = node;
     }
 
-  g_list_free (reverse_list);
-
   input  = gegl_node_get_input_proxy  (stack->graph, "input");
   output = gegl_node_get_output_proxy (stack->graph, "output");
 
diff --git a/app/widgets/gimpundoeditor.c b/app/widgets/gimpundoeditor.c
index 8a3867a..4acdea0 100644
--- a/app/widgets/gimpundoeditor.c
+++ b/app/widgets/gimpundoeditor.c
@@ -261,17 +261,16 @@ gimp_undo_editor_fill (GimpUndoEditor *editor)
                                     "name",  _("[ Base Image ]"),
                                     NULL);
 
-  /*  the list prepends its items, so first add the redo items...  */
-  for (list = GIMP_LIST (redo_stack->undos)->queue->head;
+  /*  the list prepends its items, so first add the redo items in
+   *  reverse (ascending) order...
+   */
+  for (list = GIMP_LIST (redo_stack->undos)->queue->tail;
        list;
-       list = g_list_next (list))
+       list = g_list_previous (list))
     {
       gimp_container_add (editor->container, GIMP_OBJECT (list->data));
     }
 
-  /*  ...reverse the list so the redo items are in ascending order...  */
-  gimp_list_reverse (GIMP_LIST (editor->container));
-
   /*  ...then add the undo items in descending order...  */
   for (list = GIMP_LIST (undo_stack->undos)->queue->head;
        list;


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