Slightly faster hash-table-keys and hash-table-values · emacs-mirror/emacs@4311bd0 (original) (raw)

Original file line number Diff line number Diff line change
@@ -87,11 +87,15 @@ threading."
87 87
88 88 (defsubst hash-table-keys (hash-table)
89 89 "Return a list of keys in HASH-TABLE."
90 - (cl-loop for k being the hash-keys of hash-table collect k))
90 + (let ((keys nil))
91 + (maphash (lambda (k _) (push k keys)) hash-table)
92 + keys))
91 93
92 94 (defsubst hash-table-values (hash-table)
93 95 "Return a list of values in HASH-TABLE."
94 - (cl-loop for v being the hash-values of hash-table collect v))
96 + (let ((values nil))
97 + (maphash (lambda (_ v) (push v values)) hash-table)
98 + values))
95 99
96 100 (defsubst string-empty-p (string)
97 101 "Check whether STRING is empty."