Collada: cleanup sort function for
authorGaia Clary <gaia.clary@machinimatrix.org>
Thu, 14 Jun 2012 14:48:52 +0000 (14:48 +0000)
committerGaia Clary <gaia.clary@machinimatrix.org>
Thu, 14 Jun 2012 14:48:52 +0000 (14:48 +0000)
source/blender/collada/collada_utils.cpp

index 3d9aa8e542d6182d7b867ceca94717cf70808c52..c4e336f3bc6b816cbad6a14d27e79911653d89b6 100644 (file)
@@ -230,14 +230,13 @@ void bc_remove_mark(Object *ob)
 // Use bubble sort algorithm for sorting the export set
 void bc_bubble_sort_by_Object_name(LinkNode *export_set)
 {
-       int i, j; // loop indices
-       bool unsorted = true;
+       bool sorted = false;
+       LinkNode *node;
+       for(node=export_set; node->next && !sorted; node=node->next) {
 
-       LinkNode *current;
-       int set_size = BLI_linklist_length(export_set);
-       for(i = 0; (i < set_size) && unsorted; i++) {
-               unsorted = false;
+               sorted = true;
                
+               LinkNode *current;
                for (current=export_set; current->next; current = current->next) {
                        Object *a = (Object *)current->link;
                        Object *b = (Object *)current->next->link;
@@ -248,7 +247,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
                        if (str_a.compare(str_b) > 0) {
                                current->link       = b;
                                current->next->link = a;
-                               unsorted = true;
+                               sorted = false;
                        }
                        
                }