GNU bug report logs - #59137
[PATCH] To minor changes related to overlays

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Matt Armstrong <matt@HIDDEN>; Keywords: patch; dated Tue, 8 Nov 2022 23:15:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 59137 <at> debbugs.gnu.org:


Received: (at 59137) by debbugs.gnu.org; 25 Nov 2022 01:16:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 20:16:23 2022
Received: from localhost ([127.0.0.1]:60686 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyNKI-0008VH-SI
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 20:16:23 -0500
Received: from mail-oa1-f51.google.com ([209.85.160.51]:42967)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1oyNK7-0008US-Oa
 for 59137 <at> debbugs.gnu.org; Thu, 24 Nov 2022 20:16:12 -0500
Received: by mail-oa1-f51.google.com with SMTP id
 586e51a60fabf-142b72a728fso3564010fac.9
 for <59137 <at> debbugs.gnu.org>; Thu, 24 Nov 2022 17:16:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=LNWWmlvmClk1LOmjYSIINbc4ZaUP5k+j2ORSr6GhNJg=;
 b=WXBkAhftoueKm1OmP0NFbfDKg+rKSerSmMhsSgtefWuKC7ZMMyPSmQdySbnujWH3TB
 pu2lGHbDe/uYM62UHLy40ysIeljtREb7fVPJNsD16qKIK6lQlNUTuWwHBZZMFNzwba7L
 MvjVtk/c/wfmqYuctNMGAlc6TavcwkuNGFCwUtvbsSb8iCmRwTYxHLhJcDG4eNM7jdMN
 f9moJHEj7HGHYgW7x3dgpEce+88ZizY3gnfqA/yjQY7OOTw2vGBvxQEbq9mNV5d2KMsr
 Pya60y+/CcYkIg1oDdcRF3r7LaSl5nj5U0CPYd2v54CItf+IaGQTuI5SXfeOXlqNJk5u
 iv+w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=LNWWmlvmClk1LOmjYSIINbc4ZaUP5k+j2ORSr6GhNJg=;
 b=0P9sJ9iRgScZc48RE13ejpmE155MXCbo1CshPcPp3SFG/ZlzlPsC6YDNZ2EH+4Z7nh
 T2iH7Wjm9bZMDwuc4oT5UwPHjgEvzo4WlhhhMuV9gICne/9Z4vr3UdJz0XPQB5pqHyL4
 BbFqLne4OM0qjWRuUXQmjXGWELHONJtHx+4Lw09JlIrEjdXxhK/9FuRrUhC3CN/Sd6db
 wND+5ioO2v8NnyiIThu+V+CO7QrnRfKp3XEunYC5TyVg5+E5X9hOrsBi5Ef6XEYhWLsB
 DcGPND2zVClipseZ3SPh7dhhAssLVeWJdlHSSc3HR+8Mn6LIE/Vls+hWId27F9f4Zeds
 zfnw==
X-Gm-Message-State: ANoB5pmNZbE71yYgZy28KQ0exBPpPOyk4n8Cb9IXlWU0CJrB1GA65fYK
 mnkYZirZUJYx1p7ZA5rdH70+8XoiKxls8X4dLh6U6amm9F0=
X-Google-Smtp-Source: AA0mqf5PiUMGmrYq8bDL7kVXT4xl8RgcTXzK17FkU3F2XxvsvmXN851xNNoRsQaMl6SvILM0OefJXN2cOVAZZ5uuhAg=
X-Received: by 2002:a05:6870:4995:b0:143:522a:ebcc with SMTP id
 ho21-20020a056870499500b00143522aebccmr2890096oab.199.1669338966389; Thu, 24
 Nov 2022 17:16:06 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Thu, 24 Nov 2022 17:16:06 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <87edu46r4z.fsf@HIDDEN> (Matt Armstrong's message of "Tue, 15
 Nov 2022 09:53:32 -0800")
References: <87edudm43j.fsf@HIDDEN> <834jv7rt5p.fsf@HIDDEN>
 <87edu46r4z.fsf@HIDDEN>
X-Hashcash: 1:20:221125:59137 <at> debbugs.gnu.org::uzyxwxWaDbdney7S:3DZh
MIME-Version: 1.0
Date: Thu, 24 Nov 2022 17:16:06 -0800
Message-ID: <CADwFkm=2T0Qapv+E+9Rg2Ka85BsE+=2X2ZhbJyXkm3AKLEhZJg@HIDDEN>
Subject: Re: bug#59137: [PATCH] To minor changes related to overlays
To: Matt Armstrong <matt@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59137
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 59137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Matt Armstrong <matt@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>>> +  if (!node)
>>> +    itree_iterator_finish(g);
>>                             ^
>> Please leave one space between the function's name and the open
>> parenthesis of the argument list.
>
> Ahh, yes.  Attached are new patches, rebased to current master, with
> that formatting change.

Should these patches be installed?  Stefan?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59137; Package emacs. Full text available.

Message received at 59137 <at> debbugs.gnu.org:


Received: (at 59137) by debbugs.gnu.org; 15 Nov 2022 17:53:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 15 12:53:49 2022
Received: from localhost ([127.0.0.1]:55199 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ov084-0003XB-Gc
	for submit <at> debbugs.gnu.org; Tue, 15 Nov 2022 12:53:48 -0500
Received: from relay4-d.mail.gandi.net ([217.70.183.196]:60241)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matt@HIDDEN>) id 1ov07y-0003Wq-Ql
 for 59137 <at> debbugs.gnu.org; Tue, 15 Nov 2022 12:53:47 -0500
Received: (Authenticated sender: matt@HIDDEN)
 by mail.gandi.net (Postfix) with ESMTPSA id C2EC8E0007;
 Tue, 15 Nov 2022 17:53:35 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1;
 t=1668534816;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=C2eCUlAYLMXE2jfqb7b8Z4/Pj2UW+7RJq001bm/Q+js=;
 b=RoOn6Gn0vZeRkR7hHgpj5f3PhLay54SzKcg0kADAmZ9XWq5GlOGDCxUa3Rh8PRJywsPeo7
 wgAzYdyrgjdkDT9GKSI5TwXvjLFjaZSiM97mcPRhjMp3FDuL4G53dzoVoh4161HvyceWfB
 QzwqNYiIgY4wV/KE1OWM8KFaQ0/tPwUQbP78G9C5pwe8oWWfH8dzxc0s84/2tBdmT8j29F
 XpAW148ozZzsl+vpeMU/DqbMJf7OwTCp3GbeKUThYu9d0doBcfidpYUwalMhCxRUvFsOv6
 kVbdgUjWuSoVVyDScDDzuuFFvaoxejjGFZHZOkzJWPVNY31/2fryUy+mez83yw==
Received: from matt by naz with local (Exim 4.96)
 (envelope-from <matt@HIDDEN>) id 1ov07o-000QNd-0b;
 Tue, 15 Nov 2022 09:53:32 -0800
From: Matt Armstrong <matt@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#59137: [PATCH] To minor changes related to overlays
In-Reply-To: <834jv7rt5p.fsf@HIDDEN>
References: <87edudm43j.fsf@HIDDEN> <834jv7rt5p.fsf@HIDDEN>
Date: Tue, 15 Nov 2022 09:53:32 -0800
Message-ID: <87edu46r4z.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 59137
Cc: 59137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

--=-=-=
Content-Type: text/plain

Eli Zaretskii <eliz@HIDDEN> writes:

>> +  if (!node)
>> +    itree_iterator_finish(g);
>                             ^
> Please leave one space between the function's name and the open
> parenthesis of the argument list.

Ahh, yes.  Attached are new patches, rebased to current master, with
that formatting change.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-Add-itree_empty_p-for-clarity-and-reduced-coupling.patch

From 9cdfe65ee28c68398b9305d15f178358f02f4498 Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt@HIDDEN>
Date: Tue, 8 Nov 2022 15:00:18 -0800
Subject: [PATCH 1/2] 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.
---
 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 6862cf916f..d815a199fe 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6548,7 +6548,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.  */
diff --git a/src/buffer.h b/src/buffer.h
index 2e80c8a7b0..08b0420c06 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1273,8 +1273,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,
diff --git a/src/itree.h b/src/itree.h
index 10ee0897c3..d6c6fb1059 100644
--- a/src/itree.h
+++ b/src/itree.h
@@ -25,6 +25,8 @@ #define ITREE_H
 
 #include "lisp.h"
 
+INLINE_HEADER_BEGIN
+
 /* The tree and node structs are mainly here, so they can be
    allocated.
 
@@ -117,6 +119,11 @@ #define ITREE_H
 				   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 *,
@@ -183,4 +190,6 @@ #define ITREE_FOREACH_ABORT() \
 #define ITREE_FOREACH_NARROW(beg, end) \
   itree_iterator_narrow (itree_iter_, beg, end)
 
+INLINE_HEADER_END
+
 #endif
diff --git a/src/pdumper.c b/src/pdumper.c
index 0a5d96dbb7..22d3f3f90e 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -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
-- 
2.35.1


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=0002-Simplify-ITREE_FOREACH.patch

From c2fc83ff7e7d49bdb013881453e504f21f038104 Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt@HIDDEN>
Date: Tue, 8 Nov 2022 15:08:00 -0800
Subject: [PATCH 2/2] Simplify ITREE_FOREACH

* src/itree.c (itree_iterator_next): Call itree_iterator_finish if
returning NULL.
* src/itree.h (ITREE_FOREACH): Don't call itree_iterator_finish.
---
 src/itree.c | 3 +++
 src/itree.h | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/itree.c b/src/itree.c
index ae69c97d6d..18ee6449ce 100644
--- a/src/itree.c
+++ b/src/itree.c
@@ -1431,6 +1431,9 @@ itree_iterator_next (struct itree_iterator *g)
 	 after it was pushed: Check if it still intersects. */
     } while (node && ! interval_node_intersects (node, g->begin, g->end));
 
+  if (!node)
+    itree_iterator_finish (g);
+
   return node;
 }
 
diff --git a/src/itree.h b/src/itree.h
index d6c6fb1059..67e258dd83 100644
--- a/src/itree.h
+++ b/src/itree.h
@@ -179,10 +179,9 @@ #define ITREE_FOREACH(n, t, beg, end, order)                        \
     { }                                                             \
   else                                                              \
     for (struct itree_iterator *itree_iter_                         \
-            = itree_iterator_start (t, beg, end, ITREE_##order,     \
-                                        __FILE__, __LINE__);        \
-          ((n = itree_iterator_next (itree_iter_))                  \
-           || (itree_iterator_finish (itree_iter_), false));)
+           = itree_iterator_start (t, beg, end, ITREE_##order,      \
+                                   __FILE__, __LINE__);             \
+         (n = itree_iterator_next (itree_iter_));)
 
 #define ITREE_FOREACH_ABORT() \
   itree_iterator_finish (itree_iter_)
-- 
2.35.1


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59137; Package emacs. Full text available.

Message received at 59137 <at> debbugs.gnu.org:


Received: (at 59137) by debbugs.gnu.org; 10 Nov 2022 10:38:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 10 05:38:44 2022
Received: from localhost ([127.0.0.1]:42038 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ot4xI-000888-7T
	for submit <at> debbugs.gnu.org; Thu, 10 Nov 2022 05:38:44 -0500
Received: from eggs.gnu.org ([209.51.188.92]:50386)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ot4xG-00087t-Bb
 for 59137 <at> debbugs.gnu.org; Thu, 10 Nov 2022 05:38:42 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ot4xA-00050O-3L; Thu, 10 Nov 2022 05:38:36 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=UaSfT1az+Kc64Qb+VNd6MP3mMqgYnAeDqHT680KbqVM=; b=cMvHh83MdfW7
 MCGp7OHEnLten9sOcZQ/NSo4oSwOtcawcK+WCNm1I3L6KiCT0zT4ih+rq3ES6J9NfcHpzUSpEoBOz
 p9u3Y6JbyqAvhTOTGLbMeQbqQuYRUNla5CAIPPS4wqq1htqf3q6k7qDLOyPNbn24gZyoSyEMi8sbm
 DlwdMrt2biUNIXu5jHFYObAb7V03880fbq8BCp82GHahyqzTjI/YNwFfSOzXK8gJHQLoHUOu10tgq
 bhj7HggnQAkXtXofSd2wVkmZN3teZauTY3k0SkyWC9zyePewHsZ9mwdTZ/HtxHQxkmfjpHcD3s9yg
 raNF43rcGkmGEeOtcfbwDQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1ot4x0-0001Fx-3H; Thu, 10 Nov 2022 05:38:35 -0500
Date: Thu, 10 Nov 2022 12:38:26 +0200
Message-Id: <834jv7rt5p.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Matt Armstrong <matt@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <87edudm43j.fsf@HIDDEN> (message from Matt Armstrong on Tue,
 08 Nov 2022 15:14:08 -0800)
Subject: Re: bug#59137: [PATCH] To minor changes related to overlays
References: <87edudm43j.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59137
Cc: 59137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Matt Armstrong <matt@HIDDEN>
> Date: Tue, 08 Nov 2022 15:14:08 -0800
> 
> Tags: patch
> 
> X-Debbugs-CC: Stefan Monnier <monnier@HIDDEN>

Stefan, any comments?

I have just one nit:

> diff --git a/src/itree.c b/src/itree.c
> index 989173db4e5..74199db3e42 100644
> --- a/src/itree.c
> +++ b/src/itree.c
> @@ -1431,6 +1431,9 @@ itree_iterator_next (struct itree_iterator *g)
>  	 after it was pushed: Check if it still intersects. */
>      } while (node && ! interval_node_intersects (node, g->begin, g->end));
>  
> +  if (!node)
> +    itree_iterator_finish(g);
                            ^
Please leave one space between the function's name and the open
parenthesis of the argument list.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59137; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Nov 2022 23:14:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 08 18:14:31 2022
Received: from localhost ([127.0.0.1]:38375 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1osXna-0006Mp-Gj
	for submit <at> debbugs.gnu.org; Tue, 08 Nov 2022 18:14:30 -0500
Received: from lists.gnu.org ([209.51.188.17]:52670)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matt@HIDDEN>) id 1osXnY-0006Mi-Ha
 for submit <at> debbugs.gnu.org; Tue, 08 Nov 2022 18:14:29 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <matt@HIDDEN>) id 1osXnY-0005CC-Bo
 for bug-gnu-emacs@HIDDEN; Tue, 08 Nov 2022 18:14:28 -0500
Received: from relay8-d.mail.gandi.net ([217.70.183.201])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <matt@HIDDEN>) id 1osXnN-0008LY-Pf
 for bug-gnu-emacs@HIDDEN; Tue, 08 Nov 2022 18:14:28 -0500
Received: (Authenticated sender: matt@HIDDEN)
 by mail.gandi.net (Postfix) with ESMTPSA id 3C23D1BF203
 for <bug-gnu-emacs@HIDDEN>; Tue,  8 Nov 2022 23:14:10 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1;
 t=1667949253;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type;
 bh=161aOcVUVeos8m0/SLRaF2hW9GAMNtP5TasIinDrU7Q=;
 b=aSaUX9mIIcPRsdqejrQNxVYNvq0VXpHOmrBtZSnfGqJqHvpasLDBGCdE7zbILMy+8T69Kd
 mA8aMTY7lJYEJXyowijUkUynMKxSRcPCYHaNNXVyZph7ssvYpYwfE5Cu4QyWyKsbYlecy0
 a4i4r/bXYx5jFhO40FxB9bZD3kx90aycId994uq9d5k4j4J7cbVpeFPZqZZBeqCOiGhQ44
 s6Ofmsr7P/OQKxKNcJfBdKTeofaDVrotbBJBqIkP78a5NbWCtpliebv4BZh0wMOeLhqKkW
 iQ+Mtutuml+YJpBbq5V/hBlwXE39GPtqogqUIOC9WHBoRXyop3sVYEJ4+G5oxQ==
Received: from matt by naz with local (Exim 4.96)
 (envelope-from <matt@HIDDEN>) id 1osXnE-001eak-0a
 for bug-gnu-emacs@HIDDEN; Tue, 08 Nov 2022 15:14:08 -0800
From: Matt Armstrong <matt@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] To minor changes related to overlays
Date: Tue, 08 Nov 2022 15:14:08 -0800
Message-ID: <87edudm43j.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=217.70.183.201; envelope-from=matt@HIDDEN;
 helo=relay8-d.mail.gandi.net
X-Spam_score_int: -23
X-Spam_score: -2.4
X-Spam_bar: --
X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
 DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

--=-=-=
Content-Type: text/plain

Tags: patch

X-Debbugs-CC: Stefan Monnier <monnier@HIDDEN>


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-Add-itree_empty_p-for-clarity-and-reduced-coupling.patch

From 023dddaf723aacd6579331f76f61a2741a4e52d5 Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt@HIDDEN>
Date: Tue, 8 Nov 2022 15:00:18 -0800
Subject: [PATCH 1/2] 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.
---
 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 6862cf916fb..d815a199fe0 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6548,7 +6548,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.  */
diff --git a/src/buffer.h b/src/buffer.h
index 2e80c8a7b04..08b0420c066 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1273,8 +1273,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,
diff --git a/src/itree.h b/src/itree.h
index 10ee0897c37..d6c6fb10591 100644
--- a/src/itree.h
+++ b/src/itree.h
@@ -25,6 +25,8 @@ #define ITREE_H
 
 #include "lisp.h"
 
+INLINE_HEADER_BEGIN
+
 /* The tree and node structs are mainly here, so they can be
    allocated.
 
@@ -117,6 +119,11 @@ #define ITREE_H
 				   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 *,
@@ -183,4 +190,6 @@ #define ITREE_FOREACH_ABORT() \
 #define ITREE_FOREACH_NARROW(beg, end) \
   itree_iterator_narrow (itree_iter_, beg, end)
 
+INLINE_HEADER_END
+
 #endif
diff --git a/src/pdumper.c b/src/pdumper.c
index 0a5d96dbb7c..22d3f3f90e4 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -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
-- 
2.35.1


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=0002-Simplify-ITREE_FOREACH.patch

From 67caf59c7399659a7de273c175134eac88e777ac Mon Sep 17 00:00:00 2001
From: Matt Armstrong <matt@HIDDEN>
Date: Tue, 8 Nov 2022 15:08:00 -0800
Subject: [PATCH 2/2] Simplify ITREE_FOREACH

* src/itree.c (itree_iterator_next): Call itree_iterator_finish if
returning NULL.
* src/itree.h (ITREE_FOREACH): Don't call itree_iterator_finish.
---
 src/itree.c | 3 +++
 src/itree.h | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/itree.c b/src/itree.c
index 989173db4e5..74199db3e42 100644
--- a/src/itree.c
+++ b/src/itree.c
@@ -1431,6 +1431,9 @@ itree_iterator_next (struct itree_iterator *g)
 	 after it was pushed: Check if it still intersects. */
     } while (node && ! interval_node_intersects (node, g->begin, g->end));
 
+  if (!node)
+    itree_iterator_finish(g);
+
   return node;
 }
 
diff --git a/src/itree.h b/src/itree.h
index d6c6fb10591..67e258dd832 100644
--- a/src/itree.h
+++ b/src/itree.h
@@ -179,10 +179,9 @@ #define ITREE_FOREACH(n, t, beg, end, order)                        \
     { }                                                             \
   else                                                              \
     for (struct itree_iterator *itree_iter_                         \
-            = itree_iterator_start (t, beg, end, ITREE_##order,     \
-                                        __FILE__, __LINE__);        \
-          ((n = itree_iterator_next (itree_iter_))                  \
-           || (itree_iterator_finish (itree_iter_), false));)
+           = itree_iterator_start (t, beg, end, ITREE_##order,      \
+                                   __FILE__, __LINE__);             \
+         (n = itree_iterator_next (itree_iter_));)
 
 #define ITREE_FOREACH_ABORT() \
   itree_iterator_finish (itree_iter_)
-- 
2.35.1


--=-=-=--




Acknowledgement sent to Matt Armstrong <matt@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#59137; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 25 Nov 2022 01:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.