emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] generator function optimizations


From: Paul Pogonyshev
Subject: [patch] generator function optimizations
Date: Sun, 12 Mar 2017 11:59:44 +0100

Generator functions are translated into a set of closures
that work together. While documentation says that they are
"somewhat less efficient than conventional elisp routines",
that seems to be an understatement.

In my real code (a very large function used as a co-routine)
with 60 yields, generator function has over 1000 lambdas.
I see several ways to improve this at least somewhat.

The patch below improves transformation of `progn' forms.
Here it results in 30 lambdas in the generator function fewer.
Not great (~ -3%), but I guess in other cases it can give a
larger improvement.

All unit-tests pass.

If this patch is accepted, I can work on some other ideas
I have.

Paul


* lisp/emacs-lisp/generator.el (cps--transform-1): When
transforming `progn' form with several atomic forms at the
beginning, create only one state for all of them.

Attachment: generators.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]