unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matt Armstrong <matt@rfc20.org>
To: Stefan Kangas <stefankangas@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, 59137@debbugs.gnu.org
Subject: bug#59137: [PATCH] To minor changes related to overlays
Date: Tue, 29 Nov 2022 15:16:16 -0800	[thread overview]
Message-ID: <87h6yhpd1b.fsf@rfc20.org> (raw)
In-Reply-To: <CADwFkmmLNz=HV0E6tzwmaqMwknfXuVUdy2YpF2NM_PqM=gfK9g@mail.gmail.com>

Stefan Kangas <stefankangas@gmail.com> writes:

> Matt Armstrong <matt@rfc20.org> 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 <matt@rfc20.org>
>> 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.

Thanks for the tips.


> 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.

The admittedly redundant NULL check done by itree_empty_p does not
change semantics or cause harm.  mark_overlays in alloc.c is a recursive
function so it handles NULL itself, hence the NULL check was omitted in
the original code.






  reply	other threads:[~2022-11-29 23:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 23:14 bug#59137: [PATCH] To minor changes related to overlays Matt Armstrong
2022-11-10 10:38 ` Eli Zaretskii
2022-11-15 17:53   ` Matt Armstrong
2022-11-25  1:16     ` Stefan Kangas
2022-11-25 14:48       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-26 14:05         ` Stefan Kangas
2022-11-26 19:37           ` Matt Armstrong
2022-11-26 20:07             ` Stefan Kangas
2022-11-29 23:16               ` Matt Armstrong [this message]
2022-11-30  1:28                 ` Stefan Kangas
2022-11-30 13:25                   ` Eli Zaretskii
2022-11-30 17:34                     ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6yhpd1b.fsf@rfc20.org \
    --to=matt@rfc20.org \
    --cc=59137@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).