]> git.eshelyaron.com Git - emacs.git/commitdiff
Faster implementation of map-empty-p
authorNicolas Petton <nicolas@petton.fr>
Wed, 29 Apr 2015 17:01:56 +0000 (19:01 +0200)
committerNicolas Petton <nicolas@petton.fr>
Wed, 29 Apr 2015 17:05:44 +0000 (19:05 +0200)
* lisp/emacs-lisp/map.el (map-empty-p): Faster implementation using
specific tests depending on the type of the map.

lisp/emacs-lisp/map.el

index ff0dc120c8a2aa1f6e6c50887afc122d31847f65..18d2963f46c5401a1bd24019e03d33f99c9912a2 100644 (file)
@@ -150,7 +150,11 @@ FUNCTION is called with two arguments, the key and the value."
       (arrayp map)))
 
 (defun map-empty-p (map)
-  (null (map-keys map)))
+  "Return non-nil is MAP is empty."
+  (map--dispatch map
+    :list (null map)
+    :array (seq-empty-p map)
+    :hash-table (zerop (hash-table-count map))))
 
 (defun map-contains-key-p (map key &optional testfn)
   "Return non-nil if MAP contain the key KEY, nil otherwise.