From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Opening an Org file slowed down Date: Tue, 26 Nov 2013 18:28:44 +0100 Message-ID: <877gbv8437.fsf@gmail.com> References: <87r4a7tmo2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlMR8-0004eC-TP for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 12:28:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlMR0-0000jN-CR for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 12:28:34 -0500 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]:64457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlMR0-0000jF-5w for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 12:28:26 -0500 Received: by mail-ea0-f174.google.com with SMTP id b10so3774518eae.5 for ; Tue, 26 Nov 2013 09:28:25 -0800 (PST) In-Reply-To: <87r4a7tmo2.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 23 Nov 2013 11:52:45 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Michael Brand Cc: Org Mode > Please note that the parsing process is inherently linear, since we're > in a context-dependent grammar. Thus, there's not much to do about the > parsing algorithm. > > However, the cache is always up-to-date. So, we are not bound to start > again from headline if we can find a cached element between it and the > point. The closer, the better. > > I think there's room for improvement in this area. An idea could be to > start `org-element-at-point' with an opportunistic search. Before going > back to the headline, we could, indeed, `search-backward' on > `org-element-paragraph-start' a couple of times and check if location > found is already cached. This would work well when parsing successively > elements in the same section or when editing the current paragraph. I implemented it. `org-element-at-point' runs in a mean constant time now (worst case is still linear, though). -- Nicolas Goaziou