Function: ADD-AND-FILL-SLOT-INDEX

Source

(defun add-and-fill-slot-index (rucksack class slot index-spec unique-p)
  ;; We didn't have an index but we need one now: add one.
  (let ((index (rucksack-add-slot-index rucksack class slot index-spec unique-p
                                        :errorp t))
        (slot-name (slot-definition-name slot)))
    ;; Index all instances for the new index.
    ;; NOTE: This will only work if the class is indexed, otherwise there is no
    ;; affordable way to find all instances of the class.
    (when (class-index class)
      (rucksack-map-class rucksack class
                          (lambda (object)
                            (when (slot-boundp object slot-name)
                              (index-insert index (slot-value object slot-name)
                                            object)))))))
Source Context