From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: [Accepted] Optimize org-habit-parse-todo Date: Tue, 25 Jan 2011 22:59:06 +0100 (CET) Message-ID: <20110125215906.8E76F8BAD96@carsten-dominiks-macbook-pro.local> References: <87sjwgn42k.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=40794 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjIz6-0005MR-MG for emacs-orgmode@gnu.org; Sat, 29 Jan 2011 17:09:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjIz3-00006b-62 for emacs-orgmode@gnu.org; Sat, 29 Jan 2011 17:09:32 -0500 Received: from p4fdb644b.dip.t-dialin.net ([79.219.100.75]:56065 helo=carsten-dominiks-macbook-pro.local) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjIz2-00005r-6y for emacs-orgmode@gnu.org; Sat, 29 Jan 2011 17:09:29 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Patch 558 (http://patchwork.newartisans.com/patch/558/) is now "Accepted". Maintainer comment: No comment This relates to the following submission: http://mid.gmane.org/%3C87sjwgn42k.fsf%40fastmail.fm%3E Here is the original message containing the patch: > Content-Type: text/plain; charset="utf-8" > MIME-Version: 1.0 > Content-Transfer-Encoding: 7bit > Subject: [Orgmode] Optimize org-habit-parse-todo > Date: Wed, 26 Jan 2011 01:03:47 -0000 > From: Matt Lundin > X-Patchwork-Id: 558 > Message-Id: <87sjwgn42k.fsf@fastmail.fm> > To: Carsten Dominik > Cc: Org Mode > > * lisp/org-habit.el: (org-habit-parse-todo) Don't parse more days than > needed. > > When constructing a consistency graph, org-habit now stops searching > for timestamps when the number of matches exceeds the span of time > displayed in the graph. This can lead to a significant speedup in > agenda construction, especially for entries with many logbook entries. > Previously, org-habit would parse all logbook timestamps, even if they > numbered in the hundreds. > > --- > lisp/org-habit.el | 16 ++++++++++++---- > 1 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/lisp/org-habit.el b/lisp/org-habit.el > index b174a1f..5d2514a 100644 > --- a/lisp/org-habit.el > +++ b/lisp/org-habit.el > @@ -170,10 +170,18 @@ This list represents a \"habit\" for the rest of this module." > habit-entry scheduled-repeat)) > (setq deadline (+ scheduled (- dr-days sr-days)))) > (org-back-to-heading t) > - (while (re-search-forward "- State \"DONE\".*\\[\\([^]]+\\)\\]" end t) > - (push (time-to-days > - (org-time-string-to-time (match-string-no-properties 1))) > - closed-dates)) > + (let* ((maxdays (+ org-habit-preceding-days org-habit-following-days)) > + (reversed org-log-states-order-reversed) > + (search (if reversed 're-search-forward 're-search-backward)) > + (limit (if reversed end (point))) > + (count 0)) > + (unless reversed (goto-char end)) > + (while (and (< count maxdays) > + (funcall search "- State \"DONE\".*\\[\\([^]]+\\)\\]" limit t)) > + (push (time-to-days > + (org-time-string-to-time (match-string-no-properties 1))) > + closed-dates) > + (setq count (1+ count)))) > (list scheduled sr-days deadline dr-days closed-dates)))) > > (defsubst org-habit-scheduled (habit) >