From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#58158: 29.0.50; [overlay] Interval tree iteration considered harmful Date: Sat, 01 Oct 2022 09:25:47 +0200 Message-ID: References: <83h70qhez0.fsf@gnu.org> <83edvuhaby.fsf@gnu.org> <831qruh67o.fsf@gnu.org> <83y1u2foli.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1166"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Cc: Eli Zaretskii , Andreas Politz , 58158@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 01 09:26:11 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 1oeWt0-00006v-UP for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Oct 2022 09:26:11 +0200 Original-Received: from localhost ([::1]:36948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oeWsz-000194-QF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Oct 2022 03:26:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeWss-00018v-6F for bug-gnu-emacs@gnu.org; Sat, 01 Oct 2022 03:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeWsr-0004qB-UK for bug-gnu-emacs@gnu.org; Sat, 01 Oct 2022 03:26:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oeWsr-0005p4-PY for bug-gnu-emacs@gnu.org; Sat, 01 Oct 2022 03:26:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Oct 2022 07:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58158 X-GNU-PR-Package: emacs Original-Received: via spool by 58158-submit@debbugs.gnu.org id=B58158.166460915722370 (code B ref 58158); Sat, 01 Oct 2022 07:26:01 +0000 Original-Received: (at 58158) by debbugs.gnu.org; 1 Oct 2022 07:25:57 +0000 Original-Received: from localhost ([127.0.0.1]:43566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeWsm-0005ok-P5 for submit@debbugs.gnu.org; Sat, 01 Oct 2022 03:25:57 -0400 Original-Received: from mail-ej1-f46.google.com ([209.85.218.46]:43635) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oeWsl-0005oX-NH for 58158@debbugs.gnu.org; Sat, 01 Oct 2022 03:25:56 -0400 Original-Received: by mail-ej1-f46.google.com with SMTP id lh5so13092885ejb.10 for <58158@debbugs.gnu.org>; Sat, 01 Oct 2022 00:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date; bh=ublTLgVmngEgr3/sxVqNEUE4OnoBOxZjwkVLtho+nJk=; b=qUoIy5UvAy6w9PBWT8EZG1hW7RGTVpFhf1lzxU2G8VUDtOXaRvnplwAGmAIkkuUYBb UnNVkXX1KOCe5/3++YaWwXehCmho/ogrdYNMBahB4aLnvMn9QkgAtdfr8Jd7sXPzhEjU uGizDyrGf0Vj+u4WvxEGePwFxYauFp8ZX903hKGT3EnI8MMM61upEWI9TV/snKuOMs4j rzUnwALRpZy/SV6A9ClSybagtzwVthcp1FVnnD7ZDXmi/B/JYQfj9SNmFHwjsPFN9NZU Ovu+V26RNKUGTCrL9u5c2N5VxmeZ86F47ZlAKnaB8lp/AqUNKlMJODqOZ4bJiTuhgLZH 8OzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date; bh=ublTLgVmngEgr3/sxVqNEUE4OnoBOxZjwkVLtho+nJk=; b=iBaPuY5nT2XfkV7vcFN7WRXKCY9vZW42pJ47eZ0uNe6bVAzeihdU7RBB+3KWlqawMH mwDV0fj8WM28+Ej8fdzNXi73vp/MH3EaFozqM1KWygKldcWuGD0uGv3xsNWz4gX8/uB4 +WrOwfAH1vXy68GY5FsrSxj/JOtXBbm39WHiCPJcPZ35SJ2mxpN6Pt0ZqiGHtV5Or4lZ V+bNMlecgRsF0MDdBytTt9hEL3m2vtR+klpQETx1D/c+diKKvRtTfE60cWNhKLxSgbMe YakDmyvgDZ/a27LFMfbahPvhTI1SnoS9VRqVYafF+CnpqpZfbP+ElKveeNSUonLchelR 7POQ== X-Gm-Message-State: ACrzQf0sUOScoY4/RctPqqxVSMcwLj+HWDXlYNnpDizqrU6YGOQCjW8Y uXypXTCZUD6euU4gH50LY8QcQ75g22g= X-Google-Smtp-Source: AMsMyM7bviJ5/HENSJRClSHYeTzJ3IdSizaZkXfF9+EgZnEADRP7aHzostx1O2nB/1HDXrdOQFQ9Lg== X-Received: by 2002:a17:907:9708:b0:787:6f95:2bff with SMTP id jg8-20020a170907970800b007876f952bffmr8851867ejc.81.1664609149557; Sat, 01 Oct 2022 00:25:49 -0700 (PDT) Original-Received: from Mini.fritz.box (p4fe3ace2.dip0.t-ipconnect.de. [79.227.172.226]) by smtp.gmail.com with ESMTPSA id q26-20020a17090676da00b0077ce503bd77sm2268950ejn.129.2022.10.01.00.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 00:25:48 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 30 Sep 2022 11:25:30 -0400") 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" Xref: news.gmane.io gmane.emacs.bugs:244084 Archived-At: Stefan Monnier writes: >> Maybe you could also help me with the questions below? > > I'll try (BTW, the original author is Andreas Politz who we can still > reach at . He doesn't have much time to devote > to it, tho, so best not to Cc him through all the conversations). > >> I'm assuming, from a comment somewhere, that an interval tree is an >> rb-tree with keys being interval start positions, and allowing >> duplicates. > > Yup. > >> That is, if N is a node, all nodes in the subtree N->left are strictly < >> N, and nodes in N->right are >=. > > The following code in `interval_tree_insert`: > > while (child != ITREE_NULL) > { > parent = child; > offset += child->offset; > child->limit = max (child->limit, node->end - offset); > /* This suggests that nodes in the right subtree are strictly > greater. But this is not true due to later rotations. */ > child = node->begin <= child->begin ? child->left : child->right; > } > > suggests that N->left are <= and N->right are > but my reading of the > comment is that the only thing we can rely on is that N- N->right is >= > Yup. I've used overlay-tree a bit (compile with ITREE_DEBUG defined after pulling), and used this: (defun make-ivs () (with-current-buffer (get-buffer-create "*iv*") (delete-all-overlays) (erase-buffer) (insert (make-string 50 ?x)) (let ((o1 (make-overlay 1 1)) (o2 (make-overlay 10 11)) (o3 (make-overlay 10 12)) (o4 (make-overlay 1 1)) ) (move-overlay o4 10 13) (overlay-tree)))) (pp (make-ivs)) ((:begin 10 :end 12 :limit 13 :offset 0 :rear-advance nil :front-advance nil) ((:begin 1 :end 1 :limit 13 :offset 0 :rear-advance nil :front-advance nil) nil ((:begin 10 :end 13 :limit 13 :offset 0 :rear-advance nil :front-advance nil) nil nil)) ((:begin 10 :end 11 :limit 11 :offset 0 :rear-advance nil :front-advance nil) nil nil)) That's [10, 12] / \ [1, 1] [10, 11] / \ /\ [10, 13] / \ The 10 is found "all over the place". I surmise no reasonable successor function can be written for such a tree. I have to look at std::multimap, they manage to do this somehow.