[nautilus] file-undo-operations: use g_list_prepend instead of g_list_append
- From: Alexandru-Ionut Pandelea <alexpandelea src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] file-undo-operations: use g_list_prepend instead of g_list_append
- Date: Wed, 26 Oct 2016 17:30:39 +0000 (UTC)
commit 6cc8fdedf68dec159f18cee7039ce0b8b5c1a77a
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date: Sun Oct 16 21:24:06 2016 +0300
file-undo-operations: use g_list_prepend instead of g_list_append
Use g_list_prepend and then reverse the list instead of using g_list_append,
to improve the time complexity.
src/nautilus-file-undo-operations.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-file-undo-operations.c b/src/nautilus-file-undo-operations.c
index 02508f4..61a789d 100644
--- a/src/nautilus-file-undo-operations.c
+++ b/src/nautilus-file-undo-operations.c
@@ -1146,9 +1146,11 @@ batch_rename_redo_func (NautilusFileUndoInfo *info,
old_file = l->data;
file = nautilus_file_get (old_file);
- files = g_list_append (files, file);
+ files = g_list_prepend (files, file);
}
+ files = g_list_reverse (files);
+
for (l1 = self->priv->new_display_names, l2 = files; l1 != NULL && l2 != NULL; l1 = l1->next, l2 =
l2->next)
{
old_file_name = nautilus_file_get_name (NAUTILUS_FILE (l2->data));
@@ -1223,9 +1225,11 @@ batch_rename_undo_func (NautilusFileUndoInfo *info,
new_file = l->data;
file = nautilus_file_get (new_file);
- files = g_list_append (files, file);
+ files = g_list_prepend (files, file);
}
+ files = g_list_reverse (files);
+
for (l1 = self->priv->old_display_names, l2 = files; l1 != NULL && l2 != NULL; l1 = l1->next, l2 =
l2->next)
{
old_file_name = nautilus_file_get_name (NAUTILUS_FILE (l2->data));
@@ -1362,8 +1366,10 @@ nautilus_file_undo_info_batch_rename_set_data_pre (NautilusFileUndoInfoBatchRena
old_name = g_string_new (g_file_get_basename (file));
- self->priv->old_display_names = g_list_append (self->priv->old_display_names, old_name);
+ self->priv->old_display_names = g_list_prepend (self->priv->old_display_names, old_name);
}
+
+ self->priv->old_display_names = g_list_reverse (self->priv->old_display_names);
}
void
@@ -1383,8 +1389,10 @@ nautilus_file_undo_info_batch_rename_set_data_post (NautilusFileUndoInfoBatchRen
new_name = g_string_new (g_file_get_basename (file));
- self->priv->new_display_names = g_list_append (self->priv->new_display_names, new_name);
+ self->priv->new_display_names = g_list_prepend (self->priv->new_display_names, new_name);
}
+
+ self->priv->new_display_names = g_list_reverse (self->priv->new_display_names);
}
/* trash */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]