aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 5999fcb7e7d..51c4d9c71da 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1682,17 +1682,13 @@ compact_buffer (struct buffer *buffer)
1682 if (!buffer->text->inhibit_shrinking) 1682 if (!buffer->text->inhibit_shrinking)
1683 { 1683 {
1684 /* If a buffer's gap size is more than 10% of the buffer 1684 /* If a buffer's gap size is more than 10% of the buffer
1685 size, or larger than 2000 bytes, then shrink it 1685 size, or larger than GAP_BYTES_DFL bytes, then shrink it
1686 accordingly. Keep a minimum size of 20 bytes. */ 1686 accordingly. Keep a minimum size of GAP_BYTES_MIN bytes. */
1687 int size = min (2000, max (20, (buffer->text->z_byte / 10))); 1687 ptrdiff_t size = clip_to_bounds (GAP_BYTES_MIN,
1688 1688 BUF_Z_BYTE (buffer) / 10,
1689 if (buffer->text->gap_size > size) 1689 GAP_BYTES_DFL);
1690 { 1690 if (BUF_GAP_SIZE (buffer) > size)
1691 struct buffer *save_current = current_buffer; 1691 make_gap_1 (buffer, -(BUF_GAP_SIZE (buffer) - size));
1692 current_buffer = buffer;
1693 make_gap (-(buffer->text->gap_size - size));
1694 current_buffer = save_current;
1695 }
1696 } 1692 }
1697 BUF_COMPACT (buffer) = BUF_MODIFF (buffer); 1693 BUF_COMPACT (buffer) = BUF_MODIFF (buffer);
1698 } 1694 }