summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Lundin <mdl@imapmail.org>2010-12-13 01:16:55 +0000
committerCarsten Dominik <carsten.dominik@gmail.com>2010-12-12 22:26:23 +0100
commitbca4ac99989cb010cf398ec27f72659cfeed0f52 (patch)
treeca6ae0834efb62a2d884f256ea9489130fd6394e
parentb65ba05758f2720d3f8feb1fac9dc34213f6be92 (diff)
downloadorg-mode-bca4ac99989cb010cf398ec27f72659cfeed0f52.tar.gz
Optimize calls to org-is-habit-p
* 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
-rw-r--r--lisp/org-agenda.el10
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)