diff options
| author | Paul Eggert | 2025-07-12 16:03:29 -0700 |
|---|---|---|
| committer | Paul Eggert | 2025-07-13 21:09:39 -0700 |
| commit | de0bb2e059f1c404ca328509f3eb90cdf90256c5 (patch) | |
| tree | 5a47d476f8dc8011d870e00d63ec83bb3d866701 /src/fileio.c | |
| parent | aee9b598312e282700c4eedf02b174b908479ce7 (diff) | |
| download | emacs-de0bb2e059f1c404ca328509f3eb90cdf90256c5.tar.gz emacs-de0bb2e059f1c404ca328509f3eb90cdf90256c5.zip | |
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.
Diffstat (limited to 'src/fileio.c')
| -rw-r--r-- | src/fileio.c | 4 |
1 files changed, 4 insertions, 0 deletions
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. */) | |||
| 4668 | 4668 | ||
| 4669 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ | 4669 | inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ |
| 4670 | unprocessed = 0; /* Bytes not processed in previous loop. */ | 4670 | unprocessed = 0; /* Bytes not processed in previous loop. */ |
| 4671 | file_size_hint = beg_offset; | ||
| 4671 | 4672 | ||
| 4672 | while (true) | 4673 | while (true) |
| 4673 | { | 4674 | { |
| @@ -4679,6 +4680,7 @@ by calling `format-decode', which see. */) | |||
| 4679 | if (this <= 0) | 4680 | if (this <= 0) |
| 4680 | break; | 4681 | break; |
| 4681 | 4682 | ||
| 4683 | file_size_hint += this; | ||
| 4682 | BUF_TEMP_SET_PT (XBUFFER (conversion_buffer), | 4684 | BUF_TEMP_SET_PT (XBUFFER (conversion_buffer), |
| 4683 | BUF_Z (XBUFFER (conversion_buffer))); | 4685 | BUF_Z (XBUFFER (conversion_buffer))); |
| 4684 | decode_coding_c_string (&coding, (unsigned char *) read_buf, | 4686 | decode_coding_c_string (&coding, (unsigned char *) read_buf, |
| @@ -4934,6 +4936,8 @@ by calling `format-decode', which see. */) | |||
| 4934 | } | 4936 | } |
| 4935 | } | 4937 | } |
| 4936 | 4938 | ||
| 4939 | file_size_hint = beg_offset + inserted; | ||
| 4940 | |||
| 4937 | /* Now we have either read all the file data into the gap, | 4941 | /* Now we have either read all the file data into the gap, |
| 4938 | or stop reading on I/O error or quit. If nothing was | 4942 | or stop reading on I/O error or quit. If nothing was |
| 4939 | read, undo marking the buffer modified. */ | 4943 | read, undo marking the buffer modified. */ |