mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-20 11:32:35 -08:00
Replace the C1 processor for COERCE with a compiler macro that is now activated, and in this case add a new coercion function for simple arrays.
This commit is contained in:
parent
807a1c3417
commit
01574b68bb
3 changed files with 5 additions and 4 deletions
|
|
@ -318,6 +318,5 @@
|
|||
(put-sysprop 'nth 'C1CONDITIONAL 'co1nth)
|
||||
(put-sysprop 'nthcdr 'C1CONDITIONAL 'co1nthcdr)
|
||||
|
||||
(put-sysprop 'coerce 'C1CONDITIONAL 'co1coerce)
|
||||
(put-sysprop 'cons 'C1CONDITIONAL 'co1cons)
|
||||
(put-sysprop 'ldb 'C1CONDITIONAL 'co1ldb)
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@
|
|||
(cmperror "Cannot COERCE an expression to an empty type."))
|
||||
;;
|
||||
;; No optimizations that take up too much space unless requested.
|
||||
((policy-inline-type-checks)
|
||||
((not (policy-inline-type-checks))
|
||||
form)
|
||||
;;
|
||||
;; Search for a simple template above, replacing X by the value.
|
||||
|
|
@ -265,7 +265,8 @@
|
|||
(si::closest-sequence-type type)
|
||||
(if (eq elt-type 'list)
|
||||
`(si::coerce-to-list ,value)
|
||||
`(si::coerce-to-vector ,value ',elt-type ',length))))
|
||||
`(si::coerce-to-vector ,value ',elt-type ',length
|
||||
,(and (subtypep type 'simple-array) t)))))
|
||||
;;
|
||||
;; There are no other atomic types to optimize
|
||||
((atom type)
|
||||
|
|
|
|||
|
|
@ -160,9 +160,10 @@ default value of INITIAL-ELEMENT depends on TYPE."
|
|||
((null it) (nreverse output))
|
||||
(push (seq-iterator-ref object it) output))))
|
||||
|
||||
(defun coerce-to-vector (object elt-type length)
|
||||
(defun coerce-to-vector (object elt-type length simple-array-p)
|
||||
(let ((output object))
|
||||
(unless (and (vectorp object)
|
||||
(or (null simple-array-p) (simple-array-p object))
|
||||
(eq (array-element-type object) elt-type))
|
||||
(let* ((final-length (if (eq length '*) (length object) length)))
|
||||
(setf output (make-vector elt-type final-length nil nil nil 0))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue