summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
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 /test/lisp/emacs-lisp
parenta203ad5ed0959d60f01f0265c4b658119a0b6858 (diff)
downloademacs-4311bd0bd73c17b883d3f88eab4928a44d056a3a.tar.gz
emacs-4311bd0bd73c17b883d3f88eab4928a44d056a3a.tar.bz2
emacs-4311bd0bd73c17b883d3f88eab4928a44d056a3a.zip
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 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/subr-x-tests.el7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el
index 7f3916c2c0b..0bec9db36e9 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -743,6 +743,13 @@
(with-current-buffer inner
(should-not (buffer-modified-p))))))))
+(ert-deftest subr-x--hash-table-keys-and-values ()
+ (let ((h (make-hash-table)))
+ (puthash 'a 1 h)
+ (puthash 'c 3 h)
+ (puthash 'b 2 h)
+ (should (equal (sort (hash-table-keys h) #'string<) '(a b c)))
+ (should (equal (sort (hash-table-values h) #'<) '(1 2 3)))))
(provide 'subr-x-tests)
;;; subr-x-tests.el ends here