Skip to content

Commit

Permalink
Avoid type check for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Sep 6, 2024
1 parent 0acf490 commit a07daeb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
28 changes: 15 additions & 13 deletions src/lisp/kernel/cmp/opt/opt-sequence.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,22 @@
;; types we kind of just give up.
;; MAKE-SEQUENCE handles any length check.
;; TODO: Call SEQUENCE:MAP for user sequence types, maybe.
(let ((ssyms (gensym-list sequences "SEQUENCE"))
(result (gensym "RESULT")))
(let* ((ssyms (gensym-list sequences "SEQUENCE"))
(result (gensym "RESULT"))
(result-form `(core::map-into-sequence
(make-sequence ',type
(min ,@(loop for ssym in ssyms
collect `(length ,ssym))))
,function ,@ssyms)))
`(let (,@(mapcar #'list ssyms sequences))
(let ((,result
(core::map-into-sequence
(make-sequence ',type
(min ,@(loop for ssym in ssyms
collect `(length ,ssym))))
,function ,@ssyms)))
(if (typep ,result ',type)
,result
(error 'type-error
:datum ,result
:expected-type ',type))))))))))
,(if (consp type)
`(let ((,result ,result-form))
(if (typep ,result ',type)
,result
(error 'type-error
:datum ,result
:expected-type ',type)))
result-form))))))))
form))

;;;
Expand Down
3 changes: 2 additions & 1 deletion src/lisp/kernel/lsp/seq.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ SEQUENCEs, where K is the minimum length of the given SEQUENCEs."
:initial-value (length sequence)
:key #'length))
function sequence more-sequences)))
(if (typep result result-type)
(if (or (not (consp result-type))
(typep result result-type))
result
(error 'type-error
:datum result
Expand Down

0 comments on commit a07daeb

Please sign in to comment.