From 2dd47c404208ed43a044e87843543ab35d32657e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 12 Jul 2025 16:03:29 -0700 Subject: [PATCH] insert-file-contents file size hint improvement * src/fileio.c (Finsert_file_contents): When reading yields 0, update the file size hint to match. This should improve its accuracy. (cherry picked from commit de0bb2e059f1c404ca328509f3eb90cdf90256c5) --- src/fileio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fileio.c b/src/fileio.c index b7b4320d73e..6292960b07b 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4668,6 +4668,7 @@ by calling `format-decode', which see. */) inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ unprocessed = 0; /* Bytes not processed in previous loop. */ + file_size_hint = beg_offset; while (true) { @@ -4679,6 +4680,7 @@ by calling `format-decode', which see. */) if (this <= 0) break; + file_size_hint += this; BUF_TEMP_SET_PT (XBUFFER (conversion_buffer), BUF_Z (XBUFFER (conversion_buffer))); decode_coding_c_string (&coding, (unsigned char *) read_buf, @@ -4934,6 +4936,8 @@ by calling `format-decode', which see. */) } } + file_size_hint = beg_offset + inserted; + /* Now we have either read all the file data into the gap, or stop reading on I/O error or quit. If nothing was read, undo marking the buffer modified. */ -- 2.39.5