;;; Code:
-(eval-when-compile (require 'cl))
-
+(require 'cl-lib)
(require 'eieio)
(require 'eieio-base)
Returns an alist of the key followed by the entry in a list, not a cons cell."
(let ((data (oref db data)))
(delq nil
- (loop for key in keys
- when (gethash key data)
- collect (list key (gethash key data))))))
+ (cl-loop for key in keys
+ when (gethash key data)
+ collect (list key (gethash key data))))))
(cl-defmethod registry-lookup-secondary ((db registry-db) tracksym
&optional create)
(vals (cdr-safe (nth 0 check-list)))
found)
(while (and key vals (not found))
- (setq found (case mode
+ (setq found (cl-case mode
(:member
(member (car-safe vals) (cdr-safe (assoc key entry))))
(:regex
(let ((all (plist-get spec :all))
(member (plist-get spec :member))
(regex (plist-get spec :regex)))
- (loop for k being the hash-keys of (oref db data)
- using (hash-values v)
- when (or
- ;; :all non-nil returns all
- all
- ;; member matching
- (and member (registry--match :member v member))
- ;; regex matching
- (and regex (registry--match :regex v regex)))
- collect k))))
+ (cl-loop for k being the hash-keys of (oref db data)
+ using (hash-values v)
+ when (or
+ ;; :all non-nil returns all
+ all
+ ;; member matching
+ (and member (registry--match :member v member))
+ ;; regex matching
+ (and regex (registry--match :regex v regex)))
+ collect k))))
(cl-defmethod registry-delete ((db registry-db) keys assert &rest spec)
"Delete KEYS from the registry-db THIS.
(dolist (key keys)
(let ((entry (gethash key data)))
(when assert
- (assert entry nil
- "Key %s does not exist in database" key))
+ (cl-assert entry nil "Key %s does not exist in database" key))
;; clean entry from the secondary indices
(dolist (tr tracked)
;; is this tracked symbol indexed?
"Insert ENTRY under KEY into the registry-db THIS.
Updates the secondary ('tracked') indices as well.
Errors out if the key exists already."
-
- (assert (not (gethash key (oref db data))) nil
- "Key already exists in database")
-
- (assert (not (registry-full db))
- nil
- "registry max-size limit reached")
+ (cl-assert (not (gethash key (oref db data))) nil
+ "Key already exists in database")
+ (cl-assert (not (registry-full db)) nil
+ "registry max-size limit reached")
;; store the entry
(puthash key entry (oref db data))
;; for every value in the entry under that key...
(dolist (val (cdr-safe (assq tr entry)))
(let* ((value-keys (registry-lookup-secondary-value db tr val)))
- (pushnew key value-keys :test 'equal)
+ (cl-pushnew key value-keys :test 'equal)
(registry-lookup-secondary-value db tr val value-keys))))
entry)
(let (values)
(maphash
(lambda (key v)
- (incf count)
+ (cl-incf count)
(when (and (< 0 expected)
(= 0 (mod count 1000)))
(message "reindexing: %d of %d (%.2f%%)"
(data (oref db data))
(candidates (cl-loop for k being the hash-keys of data
using (hash-values v)
- when (notany precious-p v)
+ when (cl-notany precious-p v)
collect (cons k v))))
;; We want the full entries for sorting, but should only return a
;; list of entry keys.