diff options
author | Andrea Corallo <akrl@sdf.org> | 2020-11-12 21:59:59 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2020-11-12 23:57:43 +0100 |
commit | a37cc95e21675e4f8865a9c20c8acfc158a9827a (patch) | |
tree | a42209ad04fc95ab48ec7bd0e9a6f3e47b61f33e /lisp/emacs-lisp/comp.el | |
parent | c3daee78004b8bfc3459b0f763540bdf01cc96f8 (diff) | |
download | emacs-a37cc95e21675e4f8865a9c20c8acfc158a9827a.tar.gz emacs-a37cc95e21675e4f8865a9c20c8acfc158a9827a.tar.bz2 emacs-a37cc95e21675e4f8865a9c20c8acfc158a9827a.zip |
* Memoize `comp-common-supertype'
* lisp/emacs-lisp/comp.el (comp-ctxt): Add `common-supertype-mem'
slot.
(comp-common-supertype): Memoize.
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r-- | lisp/emacs-lisp/comp.el | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 59654913977..583a3364dfa 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -308,7 +308,10 @@ This is tipically for top-level forms other than defun.") :documentation "When non-nil support late load.") (union-typesets-mem (make-hash-table :test #'equal) :type hash-table :documentation "Serve memoization for -`comp-union-typesets'.")) +`comp-union-typesets'.") + (common-supertype-mem (make-hash-table :test #'equal) :type hash-table + :documentation "Serve memoization for +`comp-common-supertype'.")) (cl-defstruct comp-args-base (min nil :type number @@ -2252,7 +2255,10 @@ PRE-LAMBDA and POST-LAMBDA are called in pre or post-order if non-nil." (defun comp-common-supertype (&rest types) "Return the first common supertype of TYPES." - (cl-reduce #'comp-common-supertype-2 types)) + (or (gethash types (comp-ctxt-common-supertype-mem comp-ctxt)) + (puthash types + (cl-reduce #'comp-common-supertype-2 types) + (comp-ctxt-common-supertype-mem comp-ctxt)))) (defsubst comp-subtype-p (type1 type2) "Return t if TYPE1 is a subtype of TYPE1 or nil otherwise." |