From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: Re: [PATCH] Fix massive slowdown in org-id-find Date: Mon, 30 Mar 2015 22:43:29 +0200 Message-ID: <877ftydxn2.fsf@sophokles.streitblatt.de> References: <87bnjj2565.fsf@sophokles.streitblatt.de> <87vbhrnz07.fsf@nicolasgoaziou.fr> <877fu6u03n.fsf@sophokles.streitblatt.de> <87twxarox9.fsf@sophokles.streitblatt.de> <877fu5mdng.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ych0Y-0002jC-EF for emacs-orgmode@gnu.org; Mon, 30 Mar 2015 17:14:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ych0T-00034L-Ar for emacs-orgmode@gnu.org; Mon, 30 Mar 2015 17:14:06 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::2]:15227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ych0S-00033Y-Se for emacs-orgmode@gnu.org; Mon, 30 Mar 2015 17:14:01 -0400 Received: from sophocles (ip-109-43-202-48.web.vodafone.de [109.43.202.48]) by smtp.strato.de (RZmta 37.4 DYNA|AUTH) with ESMTPSA id n00780r2UKhZRoc (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256)) (Client did not present a certificate) for ; Mon, 30 Mar 2015 22:43:35 +0200 (CEST) In-Reply-To: <877fu5mdng.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 25 Mar 2015 14:04:35 +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 Hello, [sorry for the delay, I had some git SNAFUs] > Could you also send and updated patch containing the VALUE optional > argument to `org-re-property' and changing modifying only the (re ...) > line in `org-find-property', with a new profiling? Seems like this does trick. I don't really understand why, though. The previous profiling seemed to indicate that most of the time was spent in `org-entry-get' (that's why I removed it). Anyway, many thanks for helping me out. Much appreciated. I attached the new patch. (let ((time (current-time))) (org-id-find "zangwill.nick_2014:aesthetic.judgment") (format "%ss" (time-to-seconds (time-subtract (current-time) time)))) --> "0.032598146s" Here is the profiler report: - command-execute 215 89% - call-interactively 215 89% - funcall-interactively 140 58% + execute-extended-command 92 38% - eval-last-sexp 35 14% - elisp--eval-last-sexp 35 14% - eval 35 14% - let 35 14% - org-id-find 35 14% - org-id-find-id-in-file 35 14% - org-find-entry-with-id 35 14% - org-find-property 35 14% - save-excursion 35 14% - let 35 14% - catch 35 14% while 35 14% + next-line 13 5% + byte-code 75 31% + redisplay_internal (C function) 15 6% + timer-event-handler 11 4% + ... 0 0% -- Florian Beck --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org.el-Allow-searching-for-specific-property-value.patch >From 389d8cec4406c394f3bf955726823951b014f6aa Mon Sep 17 00:00:00 2001 From: Florian Beck Date: Mon, 30 Mar 2015 22:27:36 +0200 Subject: [PATCH] org.el: Allow searching for specific property value * lisp/org.el (org-re-property): New optional argument. (org-find-property): Use it. --- lisp/org.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index cf37950..4f61123 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -6254,7 +6254,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. @@ -6262,14 +6262,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) @@ -16323,7 +16331,7 @@ part of the buffer." (save-excursion (goto-char (point-min)) (let ((case-fold-search t) - (re (org-re-property property nil (not value)))) + (re (org-re-property property nil (not value) value))) (catch 'exit (while (re-search-forward re nil t) (when (if value (equal value (org-entry-get (point) property nil t)) -- 2.1.0 --=-=-=--