[glib] gsequence: Improve is_end()



commit c494ae06b7bb3ba6225e485452d3acd6e458c815
Author: Garrett Regier <garrettregier gmail com>
Date:   Tue May 19 06:20:35 2015 -0700

    gsequence: Improve is_end()
    
    Instead of finding the GSequence, just walk up
    the tree and determine if the iter is the end node.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749583
    Signed-off-by: Garrett Regier <garrettregier gmail com>

 glib/gsequence.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/glib/gsequence.c b/glib/gsequence.c
index 81f3e42..8482b8b 100644
--- a/glib/gsequence.c
+++ b/glib/gsequence.c
@@ -184,20 +184,24 @@ check_iter_access (GSequenceIter *iter)
 static gboolean
 is_end (GSequenceIter *iter)
 {
-  GSequence *seq;
+  GSequenceIter *parent = iter->parent;
 
   if (iter->right)
     return FALSE;
 
-  if (!iter->parent)
+  if (!parent)
     return TRUE;
 
-  if (iter->parent->right != iter)
-    return FALSE;
+  while (parent->right == iter)
+    {
+      iter = parent;
+      parent = iter->parent;
 
-  seq = get_sequence (iter);
+      if (!parent)
+        return TRUE;
+    }
 
-  return seq->end_node == iter;
+  return FALSE;
 }
 
 typedef struct


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