From f7d8b8dfc18e5cd83177622ec273287692fca907 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Thu, 16 Jan 2025 13:32:59 -0500 Subject: [PATCH] Issue #9135 saving of xcf to network drive is slow In the above issue it was mentioned that using a buffered output stream could improve performance. This implements buffered saving for the xcf format. For testing purposes there is timing code included for now. --- app/xcf/xcf.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index b5f6f2b896..663bcda374 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -448,6 +448,14 @@ xcf_load_invoker (GimpProcedure *procedure, return return_vals; } +#define GIMP_TIMER_START() \ + { GTimer *_timer = g_timer_new (); + +#define GIMP_TIMER_END(message) \ + g_printerr ("%s: %s took %0.4f seconds\n", \ + G_STRFUNC, message, g_timer_elapsed (_timer, NULL)); \ + g_timer_destroy (_timer); } + static GimpValueArray * xcf_save_invoker (GimpProcedure *procedure, Gimp *gimp, @@ -474,8 +482,24 @@ xcf_save_invoker (GimpProcedure *procedure, if (output) { - success = xcf_save_stream (gimp, image, output, file, progress, error); + GOutputStream *buffered = NULL; + buffered = g_buffered_output_stream_new (output); + if (buffered) + { + g_printerr ("Saving using buffered stream.\n"); + GIMP_TIMER_START (); + success = xcf_save_stream (gimp, image, buffered, file, progress, error); + GIMP_TIMER_END ("Writing xcf save stream"); + g_object_unref (buffered); + } + else + { + g_printerr ("Saving unbuffered stream.\n"); + GIMP_TIMER_START (); + success = xcf_save_stream (gimp, image, output, file, progress, error); + GIMP_TIMER_END ("Writing xcf save stream"); + } g_object_unref (output); } else