all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matt Lundin <mdl@imapmail.org>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Optimize calls to org-is-habit-p
Date: Sun, 12 Dec 2010 15:16:55 -0500	[thread overview]
Message-ID: <874oai4uaj.fsf@fastmail.fm> (raw)


* lisp/org-agenda.el: (org-agenda-get-scheduled) Don't call
  org-is-habit-p until after checking for for
  org-agenda-skip-scheduled-if-done.

Org-agenda-get-scheduled was calling org-is-habit-p on every scheduled
item (including DONE items when org-agenda-skip-scheduled-if-done was
set to t). Tweaking the timing of the test shaves some time off of
agenda construction when org-habit is loaded and
org-agenda-skip-scheduled-if-done is t.

Before:  org-is-habit-p  478         0.2434439999  0.0005092970
After:   org-is-habit-p	 81          0.057944      0.0007153580
---
 lisp/org-agenda.el |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index fb26ee9..dea9d9d 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4968,12 +4968,14 @@ FRACTION is what fraction of the head-warning time has passed."
 	  (save-excursion
 	    (setq todo-state (org-get-todo-state))
 	    (setq donep (member todo-state org-done-keywords))
-	    (setq habitp (and (functionp 'org-is-habit-p)
-			      (org-is-habit-p)))
 	    (if (and donep
-		     (or habitp org-agenda-skip-scheduled-if-done
-			 (not (= diff 0))))
+		     (or org-agenda-skip-scheduled-if-done
+			 (not (= diff 0))
+			 (and (functionp 'org-is-habit-p)
+			      (org-is-habit-p))))
 		(setq txt nil)
+	      (setq habitp (and (functionp 'org-is-habit-p)
+				(org-is-habit-p)))
 	      (setq category (org-get-category))
 	      (if (not (re-search-backward "^\\*+[ \t]+" nil t))
 		  (setq txt org-agenda-no-heading-message)
-- 
1.7.3.3

             reply	other threads:[~2010-12-12 20:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 20:16 Matt Lundin [this message]
2010-12-12 21:26 ` [PATCH] Optimize calls to org-is-habit-p Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874oai4uaj.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.