Changeset 7924


Ignore:
Timestamp:
Dec 20, 2007, 2:31:51 PM (12 years ago)
Author:
wws
Message:

TYPEP was consing on a user-defined array type, due to the call to
ARRAY-DIMENSIONS in %%TYPEP. I changed it to use ARRAY-RANK and
ARRAY-DIMENSION, which slightly slows it down, not counting GC
time, but stops it from consing.

Example:

(deftype my-string () 'string)
(time (typep "foo" 'my-string)) ; Conses type structures
(time (typep "foo" 'my-string))

The final form conses 16 bytes before this change, 0 after.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-typesys.lisp

    r7918 r7924  
    36413641              ((* :maybe) t))
    36423642            (or (eq (array-ctype-dimensions type) '*)
    3643                 (do ((want (array-ctype-dimensions type) (cdr want))
    3644                      (got (array-dimensions object) (cdr got)))
    3645                     ((and (null want) (null got)) t)
    3646                   (unless (and want got
    3647                                (or (eq (car want) '*)
    3648                                    (= (car want) (car got))))
    3649                     (return nil))))
     3643                (let ((rank (array-rank object)))
     3644                  (declare (fixnum rank))
     3645                  (do* ((n 0 (1+ n))
     3646                        (want (array-ctype-dimensions type) (cdr want))
     3647                        (got (and (< n rank) (array-dimension object n))
     3648                             (and (< n rank) (array-dimension object n))))
     3649                       ((and (null want) (null got)) t)
     3650                    (declare (fixnum n))
     3651                    (unless (and want got
     3652                                 (or (eq (car want) '*)
     3653                                     (= (car want) got)))
     3654                      (return nil)))))
    36503655            (or (eq (array-ctype-element-type type) *wild-type*)
    36513656                (type= (array-ctype-specialized-element-type type)
Note: See TracChangeset for help on using the changeset viewer.