From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: noverlay branch Date: Thu, 29 Sep 2022 17:36:09 -0400 Message-ID: References: <1468ca31-1703-82a1-0c8c-be2c5b5674a7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15076"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org, matt@rfc20.org To: Gerd =?windows-1252?Q?M=F6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 29 23:37:30 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oe1Dl-0003iR-NR for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Sep 2022 23:37:29 +0200 Original-Received: from localhost ([::1]:58566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oe1Dk-0005gk-Dt for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Sep 2022 17:37:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oe1Ca-0004ui-WB for emacs-devel@gnu.org; Thu, 29 Sep 2022 17:36:18 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oe1CY-0002Qp-D8 for emacs-devel@gnu.org; Thu, 29 Sep 2022 17:36:16 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 40AB2442FE1; Thu, 29 Sep 2022 17:36:12 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 333A3442FDF; Thu, 29 Sep 2022 17:36:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1664487370; bh=LcCbnClDx2suqm+ugUFgQDiAwRQMTE2EgIEXu2YRr9U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=V+gtbSC3DwdITgrEKZKoHpnR3sB2ly3ThKWFFYA6t564vvPACfP/nLCAvML0qnjTa mH4N3ilpOKlEBadzU/E5PLWBJsw/8ulqvmK0G1UFSgfh6JfiSBf4Y09tNdVMlMWH8A JIzZBcaZUme7IfNStZTA9jBEx5YuN8ZKYb6N31SLq9EMXk1ZNY36nEjeYhFJ28LDmY PRZe3NZlymfSwyck88cQO+D3AF+Defy2y6DRf+Snh1Kv57XJcvdTG7KU8pRVxxyLpu D2dKo478qAnH8Iwss0lG7Jz3+MizxoRuornSvTO0VNcptl+pCndlq5+4e4nL2wJUfT Vs2VrdYjUf0Pg== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 088A1120872; Thu, 29 Sep 2022 17:36:10 -0400 (EDT) In-Reply-To: <1468ca31-1703-82a1-0c8c-be2c5b5674a7@gmail.com> ("Gerd =?windows-1252?Q?M=F6llmann=22's?= message of "Thu, 29 Sep 2022 16:54:14 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296485 Archived-At: >> What I'm less clear about is the use of the `null` sentinel node. >> It seems that this node is sometimes modified (e.g. its color changed >> from black to red or vice versa, and maybe also its `parent` field), >> even though it's pointed to from lots of different nodes, so any help >> documenting the way it works (or why the value in those fields doesn't >> matter) would be welcome. > > Maybe I can say something because I used a similar trick in alloc.c. > The gist of that was to make searching more elegant, and faster: > > static struct mem_node * > mem_find (void *start) > { > struct mem_node *p; > > ... > > /* Make the search always successful to speed up the loop below. */ > mem_z.start = start; > mem_z.end = (char *) start + 1; > > p = mem_root; > while (start < p->start || start >= p->end) > p = start < p->start ? p->left : p->right; > return p; > } > > If that's done for the same reason in itree.c, I don't know. A hint that it > is not, might be that each tree has a separated null node... OTOH there's a single mem tree, so in a sense you also have a separate mem_nil node per tree :-) I actually do understand the above use. What I don't understand is code such as: interval_tree_remove (struct interval_tree *tree, struct interval_node *node) { struct interval_node *broken = NULL; if (node->left == &tree->null || node->right == &tree->null) { ... } else { struct interval_node *min = interval_tree_subtree_min (tree, node->right); struct interval_node *min_right = min->right; if (!min->red) broken = min->right; if (min->parent == node) min_right->parent = min; /* set parent, if min_right = null */ where `min_right` on this last line can definitely be the null node (my tests confirm it). So what does it mean that we set the null nodes' `parent` field here? How does it interact with other places where we use the `parent` field (such as the last-but-one line where I confirmed that `min` can also be the null node). I don't see any place where we (re)set the null's `parent` field (other than in `interval_tree_clear`)? So it looks like this field is "garbage" but not completely. Stefan