emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Florian Beck <fb@miszellen.de>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Fix massive slowdown in org-id-find
Date: Mon, 23 Mar 2015 14:51:14 +0100	[thread overview]
Message-ID: <87bnjj2565.fsf@sophokles.streitblatt.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 228 bytes --]


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0362-org.el-Improve-speed-of-org-find-property.patch --]
[-- Type: text/x-diff, Size: 2620 bytes --]

From 9867f0f45befc26854920d759a2505adba5d486b Mon Sep 17 00:00:00 2001
From: Florian Beck <fb@miszellen.de>
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."
    "^\\(?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."
     (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."

             reply	other threads:[~2015-03-23 13:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 13:51 Florian Beck [this message]
2015-03-23 22:13 ` [PATCH] Fix massive slowdown in org-id-find Nicolas Goaziou
2015-03-24  9:02   ` Sebastien Vauban
2015-03-24 11:05   ` Florian Beck
2015-03-24 22:49     ` Florian Beck
2015-03-25 11:31       ` Jacob Nielsen
2015-03-25 13:04       ` Nicolas Goaziou
2015-03-30 20:43         ` Florian Beck
2015-03-31 10:01           ` Nicolas Goaziou

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:

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87bnjj2565.fsf@sophokles.streitblatt.de \
    --to=fb@miszellen.de \
    --cc=emacs-orgmode@gnu.org \


* 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 public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).