From 7cbeeabc7e6271948e7bb93020c2e4e50c65f384 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 9 Oct 2022 19:45:26 -0400 Subject: Tighten up handling of `otick` Move args between `build_overlay` and `add_buffer_overlay`, to try and keep buffer positions together with their buffer. Be more strict in the `otick` values passed to `interval_tree_insert`. Move a few things around to try and reduce dependencies through `.h` files. Fix a thinko bug in `check_tree`. * src/alloc.c (build_overlay): Remove `begin` and `end` args. * src/buffer.c (add_buffer_overlay): Move from `buffer.h`. Add `begin` and `end` args. (copy_overlays): Adjust accordingly. (Fmake_overlay): Use BUF_BEG and BUF_Z; adjust call to `build_overlay` and `add_buffer_overlay`. (Fmove_overlay): Use BUF_BEG and BUF_Z; Use the new `begin` and `end` args of `add_buffer_overlay` so we don't need to use `interval_node_set_region` when moving to a new buffer. (remove_buffer_overlay, set_overlay_region): Move from `buffer.h`. * src/buffer.h (set_overlay_region, add_buffer_overlay) (remove_buffer_overlay): Move to `buffer.c`. (build_overlay): Move from `lisp.h`. (maybe_alloc_buffer_overlays): Delete function (inline into its only caller). * src/itree.c (interval_tree_insert): Move declaration `from buffer.h`. (check_tree): Fix initial offset in call to `recurse_check_tree`. Remove redundant check of the `limit` value. (interval_node_init): Remove `begin` and `end` args. (interval_tree_insert): Mark it as static. Assert that the new node's `otick` should already be uptodate and its new parent as well. (itree_insert_node): New function. (interval_tree_insert_gap): Assert the otick of the removed+added nodes were uptodate and mark them as uptodate again after adjusting their positions. (interval_tree_inherit_offset): Check that the parent is at least as uptodate as the child. * src/lisp.h (build_overlay): Move to `buffer.h`. * src/itree.h (interval_node_init): Adjust accordingly. (interval_tree_insert): Remove declaration. (itree_insert_node): New declaration. --- src/alloc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 50968b7e121..00f2991f250 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3702,19 +3702,17 @@ build_symbol_with_pos (Lisp_Object symbol, Lisp_Object position) return val; } -/* Return a new overlay with specified START, END and PLIST. */ +/* Return a new (deleted) overlay with PLIST. */ Lisp_Object -build_overlay (ptrdiff_t begin, ptrdiff_t end, - bool front_advance, bool rear_advance, +build_overlay (bool front_advance, bool rear_advance, Lisp_Object plist) { struct Lisp_Overlay *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Overlay, plist, PVEC_OVERLAY); Lisp_Object overlay = make_lisp_ptr (p, Lisp_Vectorlike); struct interval_node *node = xmalloc (sizeof (*node)); - interval_node_init (node, begin, end, front_advance, - rear_advance, overlay); + interval_node_init (node, front_advance, rear_advance, overlay); p->interval = node; p->buffer = NULL; set_overlay_plist (overlay, plist); -- cgit v1.2.1