comparison src/alloc.c @ 41831:fa7af2e13043

(Fgarbage_collect): Shrink buffer gaps that are excessively large.
author Andrew Innes <andrewi@gnu.org>
date Wed, 05 Dec 2001 21:37:48 +0000
parents 6ec709b442c8
children a555c6419185
comparison
equal deleted inserted replaced
41830:71cbc17f7f8b 41831:fa7af2e13043
1018 String Allocation 1018 String Allocation
1019 ***********************************************************************/ 1019 ***********************************************************************/
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.
1027 1027
1028 String data is allocated from sblock structures. Strings larger 1028 String data is allocated from sblock structures. Strings larger
4094 So don't call truncate_undo_list if undo_list is Qt. */ 4094 So don't call truncate_undo_list if undo_list is Qt. */
4095 if (! EQ (nextb->undo_list, Qt)) 4095 if (! EQ (nextb->undo_list, Qt))
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 }
4102 4120
4103 gc_in_progress = 1; 4121 gc_in_progress = 1;