summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp-cstr.el
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-12-24 13:05:30 +0100
committerAndrea Corallo <akrl@sdf.org>2020-12-24 15:40:53 +0100
commitb4ee13c94218062baa4d9d15176eee4aaf582d57 (patch)
treef4cd95afb902c9f9f4ceb5717b4403dc577a2bd9 /lisp/emacs-lisp/comp-cstr.el
parent2327a983193bd043714274e78ec597592dceab80 (diff)
downloademacs-b4ee13c94218062baa4d9d15176eee4aaf582d57.tar.gz
emacs-b4ee13c94218062baa4d9d15176eee4aaf582d57.tar.bz2
emacs-b4ee13c94218062baa4d9d15176eee4aaf582d57.zip
* Memoize `comp-subtype-p'
* lisp/emacs-lisp/comp-cstr.el (comp-subtype-p): Memoize. (comp-cstr-ctxt): Add `subtype-p-mem' slot.
Diffstat (limited to 'lisp/emacs-lisp/comp-cstr.el')
-rw-r--r--lisp/emacs-lisp/comp-cstr.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 19905950b5a..32989f220a4 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -86,6 +86,9 @@ Integer values are handled in the `range' slot.")
(common-supertype-mem (make-hash-table :test #'equal) :type hash-table
:documentation "Serve memoization for
`comp-common-supertype'.")
+ (subtype-p-mem (make-hash-table :test #'equal) :type hash-table
+ :documentation "Serve memoization for
+`comp-subtype-p-mem'.")
(union-1-mem-no-range (make-hash-table :test #'equal) :type hash-table
:documentation "Serve memoization for
`comp-cstr-union-1'.")
@@ -215,7 +218,11 @@ Return them as multiple value."
(defsubst comp-subtype-p (type1 type2)
"Return t if TYPE1 is a subtype of TYPE2 or nil otherwise."
- (eq (comp-common-supertype-2 type1 type2) type2))
+ (let ((types (cons type1 type2)))
+ (or (gethash types (comp-cstr-ctxt-subtype-p-mem comp-ctxt))
+ (puthash types
+ (eq (comp-common-supertype-2 type1 type2) type2)
+ (comp-cstr-ctxt-subtype-p-mem comp-ctxt)))))
(defun comp-union-typesets (&rest typesets)
"Union types present into TYPESETS."