Source
(defmethod rucksack-map-class ((rucksack standard-rucksack) class function
&key (id-only nil) (include-subclasses t))
;; EFFICIENCY: Follow Sean Ross' suggestion and implement ID-ONLY
;; by defining a function MAP-INDEX-KEYS and then calling
;; that function here (so that we don't need to load any objects
;; that we don't want to load yet).
(let ((visited-p (make-hash-table)))
(labels ((map-instances (class)
(let ((index (rucksack-class-index rucksack class :errorp nil)))
(when index
(map-index index
(lambda (id object)
(if id-only
(funcall function id)
(funcall function object))))
(setf (gethash class visited-p) t))
(when include-subclasses
(loop for class in (class-direct-subclasses
(if (symbolp class)
(find-class class)
class))
unless (gethash class visited-p)
do (map-instances class))))))
(map-instances class))))
Source Context