]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer seq-filter in hanja-util.el
authorStefan Kangas <stefankangas@gmail.com>
Sat, 28 Oct 2023 23:40:25 +0000 (01:40 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sat, 28 Oct 2023 23:40:25 +0000 (01:40 +0200)
Benchmarking shows seq-filter to be ~30% faster on this machine.

* lisp/language/hanja-util.el (hanja-filter): Make into obsolete alias
for 'seq-filter'.  Update single caller.

lisp/language/hanja-util.el

index be0364b1c23e9b640e9bd32a22c6499ff4c82641..b5ef9230d2787e136f216a8e2b0aa265cf79c56c 100644 (file)
@@ -6479,11 +6479,7 @@ character.  This variable is initialized by `hanja-init-load'.")
     map)
   "Keymap for Hanja (Korean Hanja Converter).")
 
-(defun hanja-filter (condp lst)
-  "Construct a list from the elements of LST for which CONDP returns true."
-  (delq
-   nil
-   (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
+(define-obsolete-function-alias 'hanja-filter #'seq-filter "30.1")
 
 (defun hanja-list-prev-group ()
   "Select the previous group of hangul->hanja conversions."
@@ -6570,12 +6566,12 @@ The value is a hanja character that is selected interactively."
            0 0
            ;; Filter characters that can not be decoded.
            ;; Maybe it can not represent characters in current terminal coding.
-           (hanja-filter (lambda (x) (car x))
-                         (mapcar (lambda (c)
-                                   (if (listp c)
-                                       (cons (car c) (cdr c))
-                                     (list c)))
-                                 (aref hanja-table char)))))
+           (seq-filter #'car
+                       (mapcar (lambda (c)
+                                 (if (listp c)
+                                     (cons (car c) (cdr c))
+                                   (list c)))
+                               (aref hanja-table char)))))
     (unwind-protect
        (when (aref hanja-conversions 2)
          (catch 'exit-input-loop