From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: [PATCH] Fix massive slowdown in org-id-find Date: Mon, 23 Mar 2015 14:51:14 +0100 Message-ID: <87bnjj2565.fsf@sophokles.streitblatt.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya2lk-0005p2-3e for emacs-orgmode@gnu.org; Mon, 23 Mar 2015 09:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya2lf-0007j8-1P for emacs-orgmode@gnu.org; Mon, 23 Mar 2015 09:51:52 -0400 Received: from plane.gmane.org ([80.91.229.3]:42956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya2le-0007iv-RW for emacs-orgmode@gnu.org; Mon, 23 Mar 2015 09:51:46 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ya2lM-0001T3-2H for emacs-orgmode@gnu.org; Mon, 23 Mar 2015 14:51:28 +0100 Received: from ip-77-24-251-148.web.vodafone.de ([77.24.251.148]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 Mar 2015 14:51:28 +0100 Received: from fb by ip-77-24-251-148.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 23 Mar 2015 14:51:28 +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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi, the recent changes in org-id (presumably 8cdb2eef0f9f98f9e00a5e689decfe341fe0c6ec) lead to a massive slowdown. org-id-find is slow as it is, now I find it almost unusable. Attached patch provides a fix. -- Florian Beck --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0362-org.el-Improve-speed-of-org-find-property.patch >From 9867f0f45befc26854920d759a2505adba5d486b Mon Sep 17 00:00:00 2001 From: Florian Beck Date: Mon, 23 Mar 2015 11:35:09 +0100 Subject: [PATCH 362/362] org.el: Improve speed of org-find-property * lisp/org.el (org-re-property): New optional argument. (org-find-property): Simplify value search. --- lisp/org.el | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 85a8048..71c5e6e 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -6268,7 +6268,7 @@ takes into consideration inlinetasks." (defvar org-font-lock-keywords nil) -(defsubst org-re-property (property &optional literal allow-null) +(defsubst org-re-property (property &optional literal allow-null value) "Return a regexp matching a PROPERTY line. When optional argument LITERAL is non-nil, do not quote PROPERTY. @@ -6276,14 +6276,22 @@ This is useful when PROPERTY is a regexp. When ALLOW-NULL is non-nil, match properties even without a value. Match group 3 is set to the value when it exists. If there is no -value and ALLOW-NULL is non-nil, it is set to the empty string." +value and ALLOW-NULL is non-nil, it is set to the empty string. + +With optional argument VALUE, match only property lines with +that value; in this case, ALLOW-NULL is ignored. VALUE is quoted +unless LITERAL is non-nil." (concat "^\\(?4:[ \t]*\\)" (format "\\(?1::\\(?2:%s\\):\\)" (if literal property (regexp-quote property))) - (if allow-null - "\\(?:\\(?3:$\\)\\|[ \t]+\\(?3:.*?\\)\\)\\(?5:[ \t]*\\)$" - "[ \t]+\\(?3:[^ \r\t\n]+.*?\\)\\(?5:[ \t]*\\)$"))) + (cond (value + (format "[ \t]+\\(?3:%s\\)\\(?5:[ \t]*\\)$" + (if literal value (regexp-quote value)))) + (allow-null + "\\(?:\\(?3:$\\)\\|[ \t]+\\(?3:.*?\\)\\)\\(?5:[ \t]*\\)$") + (t + "[ \t]+\\(?3:[^ \r\t\n]+.*?\\)\\(?5:[ \t]*\\)$")))) (defconst org-property-re (org-re-property "\\S-+" 'literal t) @@ -16331,12 +16339,10 @@ part of the buffer." (save-excursion (goto-char (point-min)) (let ((case-fold-search t) - (re (org-re-property property nil (not value)))) - (catch 'exit - (while (re-search-forward re nil t) - (when (if value (equal value (org-entry-get (point) property nil t)) - (org-entry-get (point) property nil t)) - (throw 'exit (progn (org-back-to-heading t) (point))))))))) + (re (org-re-property property nil (not value) value))) + (when (re-search-forward re nil t) + (org-back-to-heading t) + (point))))) (defun org-delete-property (property) "In the current entry, delete PROPERTY." -- 2.1.0 --=-=-=--