emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-make-tags-matcher: Compile returned function
@ 2024-04-29  0:06 Morgan Smith
  2024-04-29 16:52 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Morgan Smith @ 2024-04-29  0:06 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Morgan Smith

This should result in a nice performance boost when the function is
called repeatedly (as is often done).

* lisp/org.el (org-make-tags-matcher): Evaluate returned function to
compile it into a closure.
---

Hello!

All tests pass.

I don't have any rigorous benchmarks but this does make things significantly
faster.  This actually seems to have a bigger performance impact on
`org-clock-sum' then my rewrite of `org-clock-sum' I submitted earlier does.
Which is a little frustrating honestly.

It does involve using the `eval' function which I know is a little taboo.
Although in this case I don't believe it actually adds any danger.

Thanks,

Morgan

 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 084132fb3..80ffeeccf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11726,7 +11726,7 @@ See also `org-scan-tags'."
 		     (or tagsmatcher todomatcher t))))
       (when org--matcher-tags-todo-only
 	(setq matcher `(and (member todo org-not-done-keywords) ,matcher)))
-      (cons match0 `(lambda (todo tags-list level) ,matcher)))))
+      (cons match0 (eval `(lambda (todo tags-list level) ,matcher) t)))))
 
 (defun org--tags-expand-group (group tag-groups expanded)
   "Recursively expand all tags in GROUP, according to TAG-GROUPS.
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] org-make-tags-matcher: Compile returned function
  2024-04-29  0:06 [PATCH] org-make-tags-matcher: Compile returned function Morgan Smith
@ 2024-04-29 16:52 ` Ihor Radchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-04-29 16:52 UTC (permalink / raw)
  To: Morgan Smith; +Cc: emacs-orgmode

Morgan Smith <Morgan.J.Smith@outlook.com> writes:

> This should result in a nice performance boost when the function is
> called repeatedly (as is often done).
>
> * lisp/org.el (org-make-tags-matcher): Evaluate returned function to
> compile it into a closure.
> ...
> I don't have any rigorous benchmarks but this does make things significantly
> faster.  This actually seems to have a bigger performance impact on
> `org-clock-sum' then my rewrite of `org-clock-sum' I submitted earlier does.
> Which is a little frustrating honestly.
>
> It does involve using the `eval' function which I know is a little taboo.
> Although in this case I don't believe it actually adds any danger.

I am able to reproduce a noticeable ~10% speedup.
Even better approach is byte-compiling the result. It yields ~20%
speedup.

I applied an alternative patch that byte-compiles the returned function.

Handled, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3e11b2eb8

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-29 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29  0:06 [PATCH] org-make-tags-matcher: Compile returned function Morgan Smith
2024-04-29 16:52 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).