Mercurial > hg > xemacs-beta
comparison lisp/hash-table.el @ 5271:2def0d83a5e3
Don't uselessly call #'nreverse, #'hash-table-key-list and friends.
2010-09-16 Aidan Kehoe <kehoea@parhasard.net>
* hash-table.el (hash-table-key-list, hash-table-value-list)
(hash-table-key-value-alist, hash-table-key-value-plist):
Remove some useless #'nreverse calls in these files; our hash
tables have no order, it's not helpful to pretend they do.
* behavior.el (read-behavior):
Do the same in this file, in some code evidently copied from
hash-table.el.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 16 Sep 2010 16:46:27 +0100 |
parents | 7039e6323819 |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
5270:3acaa0fc09be | 5271:2def0d83a5e3 |
---|---|
35 | 35 |
36 ;;; Code: | 36 ;;; Code: |
37 | 37 |
38 (defun hash-table-key-list (hash-table) | 38 (defun hash-table-key-list (hash-table) |
39 "Return a list of all keys in HASH-TABLE." | 39 "Return a list of all keys in HASH-TABLE." |
40 (let (lis) | 40 (let (list) |
41 (maphash #'(lambda (key val) | 41 (maphash #'(lambda (key value) (push key list)) hash-table) |
42 (push key lis)) | 42 list)) |
43 hash-table) | |
44 (nreverse lis))) | |
45 | 43 |
46 (defun hash-table-value-list (hash-table) | 44 (defun hash-table-value-list (hash-table) |
47 "Return a list of all values in HASH-TABLE." | 45 "Return a list of all values in HASH-TABLE." |
48 (let (lis) | 46 (let (list) |
49 (maphash #'(lambda (key val) | 47 (maphash #'(lambda (key value) (push value list)) hash-table) |
50 (push val lis)) | 48 list)) |
51 hash-table) | |
52 (nreverse lis))) | |
53 | 49 |
54 (defun hash-table-key-value-alist (hash-table) | 50 (defun hash-table-key-value-alist (hash-table) |
55 "Return an alist of (KEY . VALUE) for all keys and values in HASH-TABLE." | 51 "Return an alist of (KEY . VALUE) for all keys and values in HASH-TABLE." |
56 (let (lis) | 52 (let (list) |
57 (maphash #'(lambda (key val) | 53 (maphash #'(lambda (key value) (setq list (acons key value list))) |
58 (push (cons key val) lis)) | |
59 hash-table) | 54 hash-table) |
60 (nreverse lis))) | 55 list)) |
61 | 56 |
62 (defun hash-table-key-value-plist (hash-table) | 57 (defun hash-table-key-value-plist (hash-table) |
63 "Return a plist for all keys and values in HASH-TABLE. | 58 "Return a plist for all keys and values in HASH-TABLE. |
64 A plist is a simple list containing alternating keys and values." | 59 A plist is a simple list containing alternating keys and values." |
65 (let (lis) | 60 (let (list) |
66 (maphash #'(lambda (key val) | 61 (maphash #'(lambda (key value) (setq list (list* key value list))) |
67 (push key lis) | |
68 (push val lis)) | |
69 hash-table) | 62 hash-table) |
70 (nreverse lis))) | 63 list)) |