emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] map a5237a0 2/2: Faster implementation of map-empty-p


From: Nicolas Petton
Subject: [Emacs-diffs] map a5237a0 2/2: Faster implementation of map-empty-p
Date: Wed, 29 Apr 2015 17:05:59 +0000

branch: map
commit a5237a049981dbad2ecc3b17d47257ce164a8e70
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    Faster implementation of map-empty-p
    
    * 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 |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index ff0dc12..18d2963 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -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.



reply via email to

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