From: Andrea Corallo Date: Wed, 10 Apr 2024 16:45:47 +0000 (+0200) Subject: * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Improve last change. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c70359596152e2042e2679d7e220e48686ed06a3;p=emacs.git * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Improve last change. (cherry picked from commit 3eb462405e541175df99974cc06395bf191d412a) --- diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index adbbaa24a99..8d83356f20f 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -940,16 +940,27 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (null (neg cstr)) (equal (typeset cstr) '(cons))))) -(define-inline comp-cstr-type-p (cstr type) +(defun comp-cstr-type-p (cstr type) "Return t if CSTR is certainly of type TYPE." - (if-let ((pred (get type 'cl-deftype-satisfies))) + (when (with-comp-cstr-accessors - (and (null (range cstr)) - (null (neg cstr)) - (and (or (null (typeset cstr)) - (equal (typeset cstr) `(,type))) - (cl-every pred (valset cstr))))) - (error "Unknown predicate for type %s" type))) + (cl-case type + (integer + (if (or (valset cstr) (neg cstr)) + nil + (or (equal (typeset cstr) '(integer)) + (and (range cstr) + (or (null (typeset cstr)) + (equal (typeset cstr) '(integer))))))) + (t + (if-let ((pred (get type 'cl-deftype-satisfies))) + (and (null (range cstr)) + (null (neg cstr)) + (and (or (null (typeset cstr)) + (equal (typeset cstr) `(,type))) + (cl-every pred (valset cstr)))) + (error "Unknown predicate for type %s" type))))) + t)) ;; Move to comp.el? (defsubst comp-cstr-cl-tag-p (cstr)