Remove unused let variables
[gnus] / lisp / registry.el
index f26101f..44c3358 100644 (file)
 (defvar registry-db-version 0.2
   "The current version of the registry format.")
 
+(eval `
 (defclass registry-db (eieio-persistent)
   ((version :initarg :version
             :initform nil
             ;; value rather than an expression, so in order to get the value
             ;; of `most-positive-fixnum', we need to use an
             ;; expression that's not just a symbol.
-             :initform (symbol-value 'most-positive-fixnum)
+             :initform ,(symbol-value 'most-positive-fixnum)
              :type integer
              :custom integer
              :documentation "The maximum number of registry entries.")
    (data :initarg :data
          :type hash-table
          :documentation "The data hashtable.")))
+)
 
 (defmethod initialize-instance :BEFORE ((this registry-db) slots)
   "Check whether a registry object needs to be upgraded."
@@ -203,8 +205,8 @@ When CREATE is not nil, create the secondary index hashtable if needed."
       (when create
        (puthash tracksym
                 (make-hash-table :size 800 :rehash-size 2.0 :test 'equal)
-                (oref db :tracker))
-       (gethash tracksym (oref db :tracker))))))
+                (oref db tracker))
+       (gethash tracksym (oref db tracker))))))
 
 (defmethod registry-lookup-secondary-value ((db registry-db) tracksym val
                                            &optional set)
@@ -300,7 +302,7 @@ This is the key count of the `data' slot."
 (defmethod registry-full ((db registry-db))
   "Checks if registry-db THIS is full."
   (>= (registry-size db)
-      (oref db :max-size)))
+      (oref db max-size)))
 
 (defmethod registry-insert ((db registry-db) key entry)
   "Insert ENTRY under KEY into the registry-db THIS.
@@ -359,11 +361,12 @@ from the front of the list are deleted first.
 
 Returns the number of deleted entries."
   (let ((size (registry-size db))
-       (target-size (- (oref db :max-size)
-                       (* (oref db :max-size)
-                          (oref db :prune-factor))))
+       (target-size
+        (floor (- (oref db max-size)
+                  (* (oref db max-size)
+                     (oref db prune-factor)))))
        candidates)
-    (if (> size target-size)
+    (if (registry-full db)
        (progn
          (setq candidates
                (registry-collect-prune-candidates
@@ -377,7 +380,7 @@ Returns the number of deleted entries."
 Proposes only entries without the :precious keys, and attempts to
 return LIMIT such candidates.  If SORTFUNC is provided, sort
 entries first and return candidates from beginning of list."
-  (let* ((precious (oref db :precious))
+  (let* ((precious (oref db precious))
         (precious-p (lambda (entry-key)
                       (cdr (memq (car entry-key) precious))))
         (data (oref db data))
@@ -389,7 +392,7 @@ entries first and return candidates from beginning of list."
     ;; list of entry keys.
     (when sortfunc
       (setq candidates (sort candidates sortfunc)))
-    (delq nil (cl-subseq (mapcar #'car candidates) 0 limit))))
+    (cl-subseq (mapcar #'car candidates) 0 (min limit (length candidates)))))
 
 (provide 'registry)
 ;;; registry.el ends here