Changeset 12665


Ignore:
Timestamp:
05/10/10 21:13:26 (13 years ago)
Author:
ehuelsmann
Message:

Apply the speed improvement used for dispatching everywhere: all
standard classes get a constant (not a variable) assigned, because
that gets evaluated only at class-loading time, variables and
dynamic lookups get evaluated *every* time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/clos.lisp

    r12586 r12665  
    5454(export '(class-precedence-list class-slots))
    5555(defconstant +the-standard-class+ (find-class 'standard-class))
     56(defconstant +the-standard-object-class+ (find-class 'standard-object))
     57(defconstant +the-standard-method-class+ (find-class 'standard-method))
     58(defconstant +the-standard-reader-method-class+
     59  (find-class 'standard-reader-method))
     60(defconstant +the-standard-generic-function-class+
     61  (find-class 'standard-generic-function))
     62(defconstant +the-T-class+ (find-class 'T))
    5663
    5764;; Don't use DEFVAR, because that disallows loading clos.lisp
     
    557564                                             &allow-other-keys)
    558565  (let ((supers (or direct-superclasses
    559                     (list (find-class 'standard-object)))))
     566                    (list +the-standard-object-class+))))
    560567    (setf (class-direct-superclasses class) supers)
    561568    (dolist (superclass supers)
     
    580587  (getf canonical-slot :name))
    581588
    582 (defvar *extensible-built-in-classes* (list (find-class 'sequence) (find-class 'java:java-object)))
     589(defvar *extensible-built-in-classes*
     590  (list (find-class 'sequence)
     591        (find-class 'java:java-object)))
    583592
    584593(defun ensure-class (name &rest all-keys &key metaclass &allow-other-keys)
     
    741750  (set-generic-function-classes-to-emf-table gf new-value))
    742751
    743 (defvar the-class-standard-method (find-class 'standard-method))
    744 
    745752(defun (setf method-lambda-list) (new-value method)
    746753  (set-method-lambda-list method new-value))
     
    851858                                &key
    852859                                lambda-list
    853                                 (generic-function-class (find-class 'standard-generic-function))
    854                                 (method-class the-class-standard-method)
     860                                (generic-function-class +the-standard-generic-function-class+)
     861                                (method-class +the-standard-method-class+)
    855862                                (method-combination 'standard)
    856863                                (argument-precedence-order nil apo-p)
     
    886893                   :format-control "~A already names an ordinary function, macro, or special operator."
    887894                   :format-arguments (list function-name)))
    888           (setf gf (apply (if (eq generic-function-class (find-class 'standard-generic-function))
     895          (setf gf (apply (if (eq generic-function-class +the-standard-generic-function-class+)
    889896                              #'make-instance-standard-generic-function
    890897                              #'make-instance)
     
    899906  (set-funcallable-instance-function
    900907   gf
    901    (funcall (if (eq (class-of gf) (find-class 'standard-generic-function))
     908   (funcall (if (eq (class-of gf) +the-standard-generic-function-class+)
    902909                #'std-compute-discriminating-function
    903910                #'compute-discriminating-function)
     
    934941                                                documentation)
    935942  (declare (ignore generic-function-class))
    936   (let ((gf (std-allocate-instance (find-class 'standard-generic-function))))
     943  (let ((gf (std-allocate-instance +the-standard-generic-function-class+)))
    937944    (%set-generic-function-name gf name)
    938945    (setf (generic-function-lambda-list gf) lambda-list)
     
    11631170        (setf gf (ensure-generic-function name :lambda-list method-lambda-list)))
    11641171    (let ((method
    1165            (if (eq (generic-function-method-class gf) the-class-standard-method)
     1172           (if (eq (generic-function-method-class gf) +the-standard-method-class+)
    11661173               (apply #'make-instance-standard-method gf all-keys)
    11671174               (apply #'make-instance (generic-function-method-class gf) all-keys))))
     
    11781185                                      fast-function)
    11791186  (declare (ignore gf))
    1180   (let ((method (std-allocate-instance the-class-standard-method)))
     1187  (let ((method (std-allocate-instance +the-standard-method-class+)))
    11811188    (setf (method-lambda-list method) lambda-list)
    11821189    (setf (method-qualifiers method) qualifiers)
     
    13671374      methods
    13681375      (sort methods
    1369       (if (eq (class-of gf) (find-class 'standard-generic-function))
     1376      (if (eq (class-of gf) +the-standard-generic-function-class+)
    13701377    #'(lambda (m1 m2)
    13711378        (std-method-more-specific-p m1 m2 required-classes
     
    14201427  (let ((applicable-methods (%compute-applicable-methods gf args)))
    14211428    (if applicable-methods
    1422         (let ((emfun (funcall (if (eq (class-of gf) (find-class 'standard-generic-function))
     1429        (let ((emfun (funcall (if (eq (class-of gf) +the-standard-generic-function-class+)
    14231430                                  #'std-compute-effective-method-function
    14241431                                  #'compute-effective-method-function)
     
    14311438  (let ((applicable-methods (%compute-applicable-methods gf (list arg))))
    14321439    (if applicable-methods
    1433         (let ((emfun (funcall (if (eq (class-of gf) (find-class 'standard-generic-function))
     1440        (let ((emfun (funcall (if (eq (class-of gf) +the-standard-generic-function-class+)
    14341441                                  #'std-compute-effective-method-function
    14351442                                  #'compute-effective-method-function)
     
    15171524       (let ((next-emfun
    15181525              (funcall
    1519                (if (eq (class-of gf) (find-class 'standard-generic-function))
     1526               (if (eq (class-of gf) +the-standard-generic-function-class+)
    15201527                   #'std-compute-effective-method-function
    15211528                   #'compute-effective-method-function)
     
    17671774                                             slot-name)
    17681775  (declare (ignore gf))
    1769   (let ((method (std-allocate-instance (find-class 'standard-reader-method))))
     1776  (let ((method (std-allocate-instance +the-standard-reader-method-class+)))
    17701777    (setf (method-lambda-list method) lambda-list)
    17711778    (setf (method-qualifiers method) qualifiers)
     
    18181825                   :lambda-list '(new-value object)
    18191826                   :qualifiers ()
    1820                    :specializers (list (find-class 't) class)
     1827                   :specializers (list +the-T-class+ class)
    18211828;;                    :function `(function ,method-function)
    18221829                   :function (if (autoloadp 'compile)
Note: See TracChangeset for help on using the changeset viewer.