From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.bugs Subject: bug#59137: [PATCH] To minor changes related to overlays Date: Sat, 26 Nov 2022 11:37:18 -0800 Message-ID: <87k03hpkwh.fsf@rfc20.org> References: <87edudm43j.fsf@rfc20.org> <834jv7rt5p.fsf@gnu.org> <87edu46r4z.fsf@rfc20.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24065"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 59137@debbugs.gnu.org To: Stefan Kangas , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 26 20:38:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oz10C-00063Q-8k for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Nov 2022 20:38:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oz0zz-0006By-KF; Sat, 26 Nov 2022 14:38:03 -0500 Original-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 ) id 1oz0zy-0006Bj-GY for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 14:38:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oz0zy-0006x4-8L for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 14:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oz0zy-0006Ow-41 for bug-gnu-emacs@gnu.org; Sat, 26 Nov 2022 14:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Nov 2022 19:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59137 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59137-submit@debbugs.gnu.org id=B59137.166949145324599 (code B ref 59137); Sat, 26 Nov 2022 19:38:02 +0000 Original-Received: (at 59137) by debbugs.gnu.org; 26 Nov 2022 19:37:33 +0000 Original-Received: from localhost ([127.0.0.1]:41477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0zU-0006Oh-MU for submit@debbugs.gnu.org; Sat, 26 Nov 2022 14:37:33 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:34009) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oz0zR-0006OY-Kv for 59137@debbugs.gnu.org; Sat, 26 Nov 2022 14:37:31 -0500 Original-Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id CCF3EC0003; Sat, 26 Nov 2022 19:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1669491444; 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=MIBZwlTp9/qQFY/2Zk3gwj9t3mLcAWFAy8q/G1M1jGc=; b=NI5GUbc3VdMyrCStJOlx/edbo+lL2C1ewBx2CedcCVaLpVRxwsMTltreiJqUoFeEvbcWXv L0DLKIuTXgRpKI5VlrSShE3++HYpy8gj3/L5rjb968C7Q98xWYSJ78hLOj1gMdHjL7Vn8F 742V4w7HYSfaz/Nc1ur2U+5tqgd3fnmciFusyuJgZV21xKRjwPXcsLyVUvLVIqHUIvX2mW EHBTSkCriRnnTNFkQhJQB+m1bM4Lw8VoPxJGs1+f2/NmGHIHUAbjpmDP/eNwPIu+2JaGDL qSGLoGb5fnqXIGVT3rAvoZzjUttpX7G/Uho1APr9ZNAvM1EU5RjxkTDJRCOW1w== Original-Received: by mac-mini.lan (Postfix) with ESMTPS id 564E43BD4B; Sat, 26 Nov 2022 11:37:19 -0800 (PST) Original-Received: by naz.lan (Postfix, from userid 1000) id 345E043CED56; Sat, 26 Nov 2022 11:37:19 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249133 Archived-At: --=-=-= Content-Type: text/plain Stefan Kangas writes: > Stefan Monnier writes: > >>> Should these patches be installed? Stefan? >> >> I don't have an opinion on the `itree_empty_p` patch, but the one about >> `itree_iterator_finish` doesn't apply any more because >> `itree_iterator_finish` has been removed in the mean time. > > Matt, if you think these patches are still relevant, could you please > rebase them on top of current master? Thanks in advance. Hi Stefan and Stefan, 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-itree_empty_p-for-clarity-and-reduced-coupling.patch >From 3e2c4cd143d51c66198dd606e18015eeae42f3ec Mon Sep 17 00:00:00 2001 From: Matt Armstrong 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. --- 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); /* If this is an indirect buffer, mark its base buffer. */ diff --git a/src/buffer.h b/src/buffer.h index dded0cd98c..9ead875bcf 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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, diff --git a/src/itree.h b/src/itree.h index 291fa53fd3..248ea9b84d 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. @@ -114,6 +116,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 *, @@ -178,4 +185,6 @@ #define ITREE_FOREACH(n, t, beg, end, order) \ #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 fedcd3e404..35e86d2b50 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 --=-=-=--