summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/subr-x.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-06-17 19:13:33 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2022-06-17 19:16:52 +0200
commit4311bd0bd73c17b883d3f88eab4928a44d056a3a (patch)
treee04f0694be2278e180cac8db7fcc6721c178a750 /lisp/emacs-lisp/subr-x.el
parenta203ad5ed0959d60f01f0265c4b658119a0b6858 (diff)
downloademacs-4311bd0bd73c17b883d3f88eab4928a44d056a3a.tar.gz
Slightly faster hash-table-keys and hash-table-values
* lisp/emacs-lisp/subr-x.el (hash-table-keys, hash-table-values): Omit the reversal of the returned list. It is not ordered anyway. * test/lisp/emacs-lisp/subr-x-tests.el (subr-x--hash-table-keys-and-values): New test.
Diffstat (limited to 'lisp/emacs-lisp/subr-x.el')
-rw-r--r--lisp/emacs-lisp/subr-x.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 9cd793d05c5..5c3dff62c8a 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -87,11 +87,15 @@ threading."
(defsubst hash-table-keys (hash-table)
"Return a list of keys in HASH-TABLE."
- (cl-loop for k being the hash-keys of hash-table collect k))
+ (let ((keys nil))
+ (maphash (lambda (k _) (push k keys)) hash-table)
+ keys))
(defsubst hash-table-values (hash-table)
"Return a list of values in HASH-TABLE."
- (cl-loop for v being the hash-values of hash-table collect v))
+ (let ((values nil))
+ (maphash (lambda (_ v) (push v values)) hash-table)
+ values))
(defsubst string-empty-p (string)
"Check whether STRING is empty."