1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-09 13:10:57 -08:00

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.
This commit is contained in:
Paul Eggert 2025-07-12 16:03:29 -07:00
parent aee9b59831
commit de0bb2e059

View file

@ -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. */