[gnome-builder] code: short-circuit save when we think there are no changes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] code: short-circuit save when we think there are no changes
- Date: Tue, 15 Jan 2019 01:35:20 +0000 (UTC)
commit 6819d4b766effaaedc8cd23ad694e6b61440981e
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 14 17:34:41 2019 -0800
code: short-circuit save when we think there are no changes
If we have not yet gotten notification of the backing file changed, and
the buffer thinks there are no local modifications, then we can skip the
save operation.
This also helps a situation where we modify a .json flatpak manifest and
invalidate the build pipelines immediately due to the inotify event.
Fixes #757
src/libide/code/ide-buffer.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/src/libide/code/ide-buffer.c b/src/libide/code/ide-buffer.c
index 0131c84e3..a4bfe4f71 100644
--- a/src/libide/code/ide-buffer.c
+++ b/src/libide/code/ide-buffer.c
@@ -1496,6 +1496,18 @@ ide_buffer_save_file_async (IdeBuffer *self,
source_file = alternate;
}
+ /* Possibly avoid any writing if we can detect a no-change state */
+ if (file == NULL || g_file_equal (file, ide_buffer_get_file (self)))
+ {
+ if (!self->changed_on_volume &&
+ !gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (self)))
+ {
+ ide_notification_set_progress (local_notif, 1.0);
+ ide_task_return_boolean (task, TRUE);
+ IDE_GOTO (set_out_param);
+ }
+ }
+
if (self->addins != NULL)
{
IdeBufferFileSave closure = { self, file };
@@ -1515,6 +1527,7 @@ ide_buffer_save_file_async (IdeBuffer *self,
ide_buffer_save_file_cb,
g_steal_pointer (&task));
+set_out_param:
if (notif != NULL)
*notif = g_steal_pointer (&local_notif);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]