[gnome-builder] back-forward-list: finish incomplete save cleanup



commit c431b32e762471e0f071355217f502520b6d72f6
Author: Christian Hergert <chergert redhat com>
Date:   Sat Dec 5 01:37:24 2015 -0800

    back-forward-list: finish incomplete save cleanup
    
    Looks like we only did half the battle here. Finish up by creating state
    that can be used during collection.

 libide/ide-back-forward-list-save.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/libide/ide-back-forward-list-save.c b/libide/ide-back-forward-list-save.c
index 476abe0..f1ede79 100644
--- a/libide/ide-back-forward-list-save.c
+++ b/libide/ide-back-forward-list-save.c
@@ -35,8 +35,8 @@ ide_back_forward_list_save_collect (gpointer data,
 {
   IdeBackForwardListSave *state = user_data;
   IdeBackForwardItem *item = data;
-  g_autofree gchar *hash_key = NULL;
   g_autofree gchar *str = NULL;
+  gchar *hash_key = NULL;
   IdeUri *uri;
   gsize count;
 
@@ -91,8 +91,8 @@ _ide_back_forward_list_save_async (IdeBackForwardList  *self,
                                    GAsyncReadyCallback  callback,
                                    gpointer             user_data)
 {
+  IdeBackForwardListSave state = { 0 };
   g_autoptr(GTask) task = NULL;
-  GString *content;
   GBytes *bytes;
 
   g_return_if_fail (IDE_IS_BACK_FORWARD_LIST (self));
@@ -110,10 +110,13 @@ _ide_back_forward_list_save_async (IdeBackForwardList  *self,
 
   task = g_task_new (self, cancellable, callback, user_data);
 
-  content = g_string_new (NULL);
-  _ide_back_forward_list_foreach (self, ide_back_forward_list_save_collect, content);
-  bytes = g_bytes_new_take (content->str, content->len + 1);
-  g_string_free (content, FALSE);
+  state.content = g_string_new (NULL);
+  state.counter = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+  _ide_back_forward_list_foreach (self, ide_back_forward_list_save_collect, &state);
+  bytes = g_bytes_new_take (state.content->str, state.content->len + 1);
+  g_string_free (state.content, FALSE);
+  g_hash_table_unref (state.counter);
 
   g_file_replace_contents_bytes_async (file,
                                        bytes,


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