From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#70077: An easier way to track buffer changes Date: Wed, 03 Apr 2024 12:34:47 +0000 Message-ID: <8734s2pqu0.fsf@localhost> References: <86frw8ewk9.fsf@gnu.org> <86cyrcdy80.fsf@gnu.org> <877chh8fjk.fsf@localhost> <87wmpfsv2y.fsf@localhost> <87ttkjspkq.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23237"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 70077@debbugs.gnu.org, qhong@alum.mit.edu, frederic.bour@lakaban.net, joaotavora@gmail.com, mail@nicolasgoaziou.fr, acm@muc.de, Eli Zaretskii , stephen_leake@stephe-leake.org, alan.zimm@gmail.com, phillip.lord@russet.org.uk To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 03 14:35:42 2024 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 1rrzqA-0005lH-EL for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Apr 2024 14:35:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrzpn-0006c3-Gj; Wed, 03 Apr 2024 08:35:19 -0400 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 1rrzpT-0006Ma-55 for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2024 08:35:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rrzpS-0003Cd-QB for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2024 08:34:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrzpX-0005cf-3K for bug-gnu-emacs@gnu.org; Wed, 03 Apr 2024 08:35:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Apr 2024 12:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70077 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70077-submit@debbugs.gnu.org id=B70077.171214769021516 (code B ref 70077); Wed, 03 Apr 2024 12:35:03 +0000 Original-Received: (at 70077) by debbugs.gnu.org; 3 Apr 2024 12:34:50 +0000 Original-Received: from localhost ([127.0.0.1]:57309 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrzpK-0005ax-Do for submit@debbugs.gnu.org; Wed, 03 Apr 2024 08:34:50 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:45619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrzpE-0005Zt-Lq for 70077@debbugs.gnu.org; Wed, 03 Apr 2024 08:34:47 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id AFFDA240103 for <70077@debbugs.gnu.org>; Wed, 3 Apr 2024 14:34:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1712147674; bh=Kn4hJ4Epmhcxy1k0wUp6vHoWYHsJbZ13QKr6Jw3RNgE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=QBBwst8Rdda11QPafUdYgdL48AyKZg5/Kl1+/qL3HSYNROjarP6uYFwR5GnyaNrPS cNlQc3IjQ5Rwjvs0XYsgQAsb6XAxTLhdXs78P9VrJSSTUiWyYelADpV5Obt4TBJt1o dNcg/GaW5JdXTs7DFuyBedeCpOETuSB6Pv+zDbIvfaYeborVF5jBzlVK5tXcO17T7R ZYNx9v0WOVQMo+HJ6uVtToqG3x8R9IlYzQiY19m7ycrIfrkMC+HthEe+XIzx8uSeWM MGIPPOTEXxJNclefNi9qte9fK3QfmKzhqOGd3JifbBYorrwWWM9b8fl5uyRuDPjnVU h3gDpMeD5epAg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V8khm0r61z9rxM; Wed, 3 Apr 2024 14:34:31 +0200 (CEST) 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:282569 Archived-At: Stefan Monnier writes: >> My reading of `track-changes--before' is that `concat' is called on >> every change except when a new change is already inside the previously >> recorded one. > > The "previously recorded one" (i.e. the info stored in > `track-changes--before-beg/end/string`) is a conservative > over-approximation of the changed area. We (at least) double its size > every time we have to grow it, specifically to reduce the number of > times we need to grow it (otherwise we quickly fall into the O(N=C2=B2) > trap). I am not 100% where the O(N^2) is coming from. I'd rather see the "doubling" explained better in the comment before the code. In any case, while I do see where the idea of over-expanding the region comes from, it is not ideal for my use-case in Org mode - it is often critical to know precise region where the change happened. Larger region spanning over more lines than needed can easily trigger re-parsing too much, especially when changes are being made near Org heading lines. In worst-case scenario, Org mode has to drop parser cache for the whole edited subtree repeatedly, slowing things down by orders of magnitude. And this is not a theoretical consideration - I had to tweak things considerably in the past for certain Org mass-editing commands in order to not slow them down because of repeated cache drops. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at