Subject: Re: bug#59137: [PATCH] To minor changes related to overlays

From: Stefan Kangas <[email-masked]>
Date: Sat, 26 Nov 2022 12:07:28 -0800

Matt Armstrong <[email-masked]> writes:

> Attached is the rebased patch for the new helper function (it didn't
> change much if at all).  As Stefan suggested, the patch for the iterator
> is no longer relevant.

Thanks.

> From 3e2c4cd143d51c66198dd606e18015eeae42f3ec Mon Sep 17 00:00:00 2001
> From: Matt Armstrong <[email-masked]>
> Date: Tue, 8 Nov 2022 15:00:18 -0800
> Subject: [PATCH] Add itree_empty_p for clarity and reduced coupling
>
> * src/itree.h (itree_empty_p): New predicate.
> * src/buffer.h (buffer_has_overlays): Call it.
> * src/pdumper.c (dump_buffer): ditto.
> * src/alloc.c (mark_buffer): ditto.

Equivalently, you can leave out "ditto" so the above is just the below
(I added the bug number too, according to our conventions):

* 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)

> ---
>  src/alloc.c   | 2 +-
>  src/buffer.h  | 3 +--
>  src/itree.h   | 9 +++++++++
>  src/pdumper.c | 2 +-
>  4 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/alloc.c b/src/alloc.c
> index 0653f2e0cc..526a25393f 100644
> --- a/src/alloc.c
> +++ b/src/alloc.c
> @@ -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);

I'm not familiar with this code at all, but I note that the condition
here changes from:

    buffer->overlays

to

    buffer->overlays && buffer->overlays->root

Is that correct?  Unless I missed something, the patch description
doesn't say anything about it.