[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp a37cc95 4/6: * Memoize `comp-common-supertype'
From: |
Andrea Corallo |
Subject: |
feature/native-comp a37cc95 4/6: * Memoize `comp-common-supertype' |
Date: |
Thu, 12 Nov 2020 18:11:56 -0500 (EST) |
branch: feature/native-comp
commit a37cc95e21675e4f8865a9c20c8acfc158a9827a
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* Memoize `comp-common-supertype'
* lisp/emacs-lisp/comp.el (comp-ctxt): Add `common-supertype-mem'
slot.
(comp-common-supertype): Memoize.
---
lisp/emacs-lisp/comp.el | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 5965491..583a336 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."
- feature/native-comp updated (2435c10 -> 9bb2fc1), Andrea Corallo, 2020/11/12
- feature/native-comp 6f10e0f 2/6: * Rework `comp-ret-type-spec' in terms of `comp-phi', Andrea Corallo, 2020/11/12
- feature/native-comp c3daee7 3/6: * Add few more type specifier tests, Andrea Corallo, 2020/11/12
- feature/native-comp c4749ce 1/6: * Move phi function code into dedicated function and improve it, Andrea Corallo, 2020/11/12
- feature/native-comp 9bb2fc1 6/6: Add copy insn testcase, Andrea Corallo, 2020/11/12
- feature/native-comp c412d39 5/6: * lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p): Fix logic., Andrea Corallo, 2020/11/12
- feature/native-comp a37cc95 4/6: * Memoize `comp-common-supertype',
Andrea Corallo <=