[gnome-builder/wip/libide-merge] prune large back/forward lists



commit 942538d3f3a573ed6b4731f38f376f8320a2ed56
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 20 23:56:05 2015 -0700

    prune large back/forward lists

 libide/ide-back-forward-list.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-back-forward-list.c b/libide/ide-back-forward-list.c
index 5b3a9b4..5726d3e 100644
--- a/libide/ide-back-forward-list.c
+++ b/libide/ide-back-forward-list.c
@@ -149,6 +149,20 @@ ide_back_forward_list_get_can_go_forward (IdeBackForwardList *self)
   return (self->forward->length > 0);
 }
 
+static void
+ide_back_forward_list_prune (IdeBackForwardList *self)
+{
+  g_assert (IDE_IS_BACK_FORWARD_LIST (self));
+
+  while (self->backward->length > MAX_ITEMS_TOTAL)
+    {
+      IdeBackForwardList *item;
+
+      item = g_queue_pop_tail (self->backward);
+      g_clear_object (&item);
+    }
+}
+
 void
 ide_back_forward_list_push (IdeBackForwardList *self,
                             IdeBackForwardItem *item)
@@ -189,6 +203,8 @@ ide_back_forward_list_push (IdeBackForwardList *self,
   else
     self->current_item = g_object_ref (item);
 
+  ide_back_forward_list_prune (self);
+
   g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_BACKWARD]);
   g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_CAN_GO_FORWARD]);
 


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