mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-02 15:40:55 -08:00
Optimize clos::safe-instance-ref
This commit is contained in:
parent
4b753ce2e7
commit
8f6fbb87cb
1 changed files with 12 additions and 4 deletions
|
|
@ -488,14 +488,22 @@ because it contains a reference to the undefined class~% ~A"
|
|||
;;; Optional accessors
|
||||
;;;
|
||||
|
||||
(defun unbound-slot-error (object index)
|
||||
(declare (type standard-object object)
|
||||
(type fixnum index)
|
||||
(si::c-local))
|
||||
(let* ((class (class-of object))
|
||||
(slotd (find index (class-slots class) :key #'slot-definition-location)))
|
||||
(values (slotd-unbound class object (slot-definition-name slotd)))))
|
||||
|
||||
(defun safe-instance-ref (object index)
|
||||
(declare (fixnum index))
|
||||
(declare (type standard-object object)
|
||||
(type fixnum index)
|
||||
(optimize (safety 0)))
|
||||
(let ((value (si:instance-ref object index)))
|
||||
(if (si:sl-boundp value)
|
||||
value
|
||||
(let ((class (class-of object))
|
||||
(slotd (find index (class-slots class) :key #'slot-definition-location)))
|
||||
(values (slotd-unbound class object (slot-definition-name slotd)))))))
|
||||
(unbound-slot-error object index))))
|
||||
|
||||
;;; The following does not get as fast as it should because we are not
|
||||
;;; allowed to memoize the position of a slot. The problem is that the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue