Add itree_empty_p for clarity and reduced coupling
* src/itree.h (itree_empty_p): New predicate. * src/buffer.h (buffer_has_overlays): * src/pdumper.c (dump_buffer): * src/alloc.c (mark_buffer): Call it. (Bug#59137)
This commit is contained in:
parent
32615c9bc1
commit
656a54b823
4 changed files with 12 additions and 4 deletions
|
@ -6553,7 +6553,7 @@ mark_buffer (struct buffer *buffer)
|
|||
if (!BUFFER_LIVE_P (buffer))
|
||||
mark_object (BVAR (buffer, undo_list));
|
||||
|
||||
if (buffer->overlays)
|
||||
if (!itree_empty_p (buffer->overlays))
|
||||
mark_overlays (buffer->overlays->root);
|
||||
|
||||
/* If this is an indirect buffer, mark its base buffer. */
|
||||
|
|
|
@ -1277,8 +1277,7 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
|
|||
INLINE bool
|
||||
buffer_has_overlays (void)
|
||||
{
|
||||
return current_buffer->overlays
|
||||
&& (current_buffer->overlays->root != NULL);
|
||||
return !itree_empty_p (current_buffer->overlays);
|
||||
}
|
||||
|
||||
/* Functions for accessing a character or byte,
|
||||
|
|
|
@ -25,6 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
|||
|
||||
#include "lisp.h"
|
||||
|
||||
INLINE_HEADER_BEGIN
|
||||
|
||||
/* The tree and node structs are mainly here, so they can be
|
||||
allocated.
|
||||
|
||||
|
@ -114,6 +116,11 @@ extern void itree_node_set_region (struct itree_tree *, struct itree_node *,
|
|||
ptrdiff_t, ptrdiff_t);
|
||||
extern struct itree_tree *itree_create (void);
|
||||
extern void itree_destroy (struct itree_tree *);
|
||||
INLINE bool
|
||||
itree_empty_p (struct itree_tree *tree)
|
||||
{
|
||||
return !tree || !tree->root;
|
||||
}
|
||||
extern intmax_t itree_size (struct itree_tree *);
|
||||
extern void itree_clear (struct itree_tree *);
|
||||
extern void itree_insert (struct itree_tree *, struct itree_node *,
|
||||
|
@ -178,4 +185,6 @@ struct itree_iterator
|
|||
#define ITREE_FOREACH_NARROW(beg, end) \
|
||||
itree_iterator_narrow (itree_iter_, beg, end)
|
||||
|
||||
INLINE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2863,7 +2863,7 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
|
|||
DUMP_FIELD_COPY (out, buffer, inhibit_buffer_hooks);
|
||||
DUMP_FIELD_COPY (out, buffer, long_line_optimizations_p);
|
||||
|
||||
if (buffer->overlays && buffer->overlays->root != NULL)
|
||||
if (!itree_empty_p (buffer->overlays))
|
||||
/* We haven't implemented the code to dump overlays. */
|
||||
emacs_abort ();
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue