From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [PATCH] Optimize calls to org-is-habit-p Date: Sun, 12 Dec 2010 15:16:55 -0500 Message-ID: <874oai4uaj.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=46870 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PRsQM-0005nb-My for emacs-orgmode@gnu.org; Sun, 12 Dec 2010 15:21:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PRsQL-0000FW-EP for emacs-orgmode@gnu.org; Sun, 12 Dec 2010 15:21:38 -0500 Received: from out3.smtp.messagingengine.com ([66.111.4.27]:40128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PRsQL-0000Ch-Ap for emacs-orgmode@gnu.org; Sun, 12 Dec 2010 15:21:37 -0500 Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id B60F0CBC for ; Sun, 12 Dec 2010 15:20:53 -0500 (EST) Received: from archdesk (67-197-63-212.rh2.dyn.cm.comporium.net [67.197.63.212]) by mail.messagingengine.com (Postfix) with ESMTPSA id 671CE5E577D for ; Sun, 12 Dec 2010 15:20:53 -0500 (EST) 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: Org Mode * 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