emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a94202b: Reuse `alist-get' in map.el


From: Nicolas Petton
Subject: [Emacs-diffs] master a94202b: Reuse `alist-get' in map.el
Date: Sun, 21 Jun 2015 18:27:15 +0000

branch: master
commit a94202b78a8a1ecbb623e76f7feeb3bffc954f12
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    Reuse `alist-get' in map.el
    
    * lisp/emacs-lisp/map.el (map-elt): Use `alist-get' to retrieve alist
    elements.
---
 lisp/emacs-lisp/map.el |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index f5a9fd9..1d8a312 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -106,11 +106,11 @@ form.
   "Perform a lookup in MAP of KEY and return its associated value.
 If KEY is not found, return DEFAULT which defaults to nil.
 
-If MAP is a list, `equal' is used to lookup KEY.
+If MAP is a list, `eql' is used to lookup KEY.
 
 MAP can be a list, hash-table or array."
   (map--dispatch map
-    :list (map--elt-list map key default)
+    :list (alist-get key map default)
     :hash-table (gethash key map default)
     :array (map--elt-array map key default)))
 
@@ -324,14 +324,6 @@ MAP can be a list, hash-table or array."
                  (setq index (1+ index))))
              map)))
 
-(defun map--elt-list (map key &optional default)
-  "Lookup, in the list MAP, the value associated with KEY and return it.
-If KEY is not found, return DEFAULT which defaults to nil."
-  (let ((pair (assoc key map)))
-    (if pair
-        (cdr pair)
-      default)))
-
 (defun map--elt-array (map key &optional default)
   "Return the element of the array MAP at the index KEY.
 If KEY is not found, return DEFAULT which defaults to nil."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]