Method: (RUCKSACK-UPDATE-SLOT-INDEXES STANDARD-RUCKSACK PERSISTENT-CLASS)

Source

(defmethod rucksack-update-slot-indexes ((rucksack standard-rucksack)
                                         (class persistent-class))
  (let ((direct-slots (class-direct-slots class))
        (indexed-slot-names (rucksack-indexed-slots-for-class rucksack class)))
    ;; Remove indexes for slots that don't exist anymore.
    (loop for slot-name in indexed-slot-names
          unless (find slot-name direct-slots :key #'slot-definition-name)
          do (rucksack-remove-slot-index rucksack class slot-name :errorp nil))
    ;; Update indexes for the current set of direct slots.
    (dolist (slot direct-slots)
      (let ((index-spec (and (slot-persistence slot)
                             (or (find-index-spec (slot-index slot) :errorp nil)
                                 (slot-index slot))))
            (unique-p (slot-unique slot))
            (slot-name (slot-definition-name slot)))
        (let* ((current-index (rucksack-slot-index rucksack class slot-name
                                                   :errorp nil
                                                   :include-superclasses nil))
               (current-index-spec (and current-index (index-spec current-index)))
               (current-unique-p (and current-index (index-unique-keys-p current-index))))
          (cond ((and (index-spec-equal index-spec current-index-spec)
                      (eql unique-p current-unique-p))
                 ;; We keep the same index: no change needed.
                 :no-change)
                ((and current-index-spec (null index-spec))
                 ;; The index is not wanted anymore: remove it.
                 (rucksack-remove-slot-index rucksack class slot :errorp t))
                ((and (null current-index-spec) index-spec)
                 ;; We didn't have an index but we need one now: add one.
                 (add-and-fill-slot-index rucksack class slot index-spec unique-p))
                ((and current-index-spec index-spec)
                 ;; We have an index but need a different one now.
                 (replace-slot-index rucksack class slot index-spec unique-p))))))))
Source Context