diff options
| author | Andrew Innes | 2001-12-05 21:39:01 +0000 |
|---|---|---|
| committer | Andrew Innes | 2001-12-05 21:39:01 +0000 |
| commit | e0fead5d9f0536f821b870eea67c1a399111ceea (patch) | |
| tree | 7a4fd0f53017acad1549c13854e3f90eb8654348 /src/alloc.c | |
| parent | 8af5b8e71f0f24a486efd7b9e4713ce44629df2e (diff) | |
| download | emacs-e0fead5d9f0536f821b870eea67c1a399111ceea.tar.gz emacs-e0fead5d9f0536f821b870eea67c1a399111ceea.zip | |
(Fgarbage_collect): Shrink buffer gaps that are
excessively large.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index 94ad4d59df7..6a47b872d23 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1020,7 +1020,7 @@ make_number (n) | |||
| 1020 | 1020 | ||
| 1021 | /* Lisp_Strings are allocated in string_block structures. When a new | 1021 | /* Lisp_Strings are allocated in string_block structures. When a new |
| 1022 | string_block is allocated, all the Lisp_Strings it contains are | 1022 | string_block is allocated, all the Lisp_Strings it contains are |
| 1023 | added to a free-list stiing_free_list. When a new Lisp_String is | 1023 | added to a free-list string_free_list. When a new Lisp_String is |
| 1024 | needed, it is taken from that list. During the sweep phase of GC, | 1024 | needed, it is taken from that list. During the sweep phase of GC, |
| 1025 | string_blocks that are entirely free are freed, except two which | 1025 | string_blocks that are entirely free are freed, except two which |
| 1026 | we keep. | 1026 | we keep. |
| @@ -4096,6 +4096,24 @@ Garbage collection happens automatically if you cons more than | |||
| 4096 | nextb->undo_list | 4096 | nextb->undo_list |
| 4097 | = truncate_undo_list (nextb->undo_list, undo_limit, | 4097 | = truncate_undo_list (nextb->undo_list, undo_limit, |
| 4098 | undo_strong_limit); | 4098 | undo_strong_limit); |
| 4099 | |||
| 4100 | /* Shrink buffer gaps, but skip indirect and dead buffers. */ | ||
| 4101 | if (nextb->base_buffer == 0 && !NILP (nextb->name)) | ||
| 4102 | { | ||
| 4103 | /* If a buffer's gap size is more than 10% of the buffer | ||
| 4104 | size, or larger than 2000 bytes, then shrink it | ||
| 4105 | accordingly. Keep a minimum size of 20 bytes. */ | ||
| 4106 | int size = min (2000, max (20, (nextb->text->z_byte / 10))); | ||
| 4107 | |||
| 4108 | if (nextb->text->gap_size > size) | ||
| 4109 | { | ||
| 4110 | struct buffer *save_current = current_buffer; | ||
| 4111 | current_buffer = nextb; | ||
| 4112 | make_gap (-(nextb->text->gap_size - size)); | ||
| 4113 | current_buffer = save_current; | ||
| 4114 | } | ||
| 4115 | } | ||
| 4116 | |||
| 4099 | nextb = nextb->next; | 4117 | nextb = nextb->next; |
| 4100 | } | 4118 | } |
| 4101 | } | 4119 | } |