changeset 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 3acaa0fc09be
children 66dbef5f8076
files lisp/ChangeLog lisp/behavior.el lisp/hash-table.el
diffstat 3 files changed, 27 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Sep 16 15:58:10 2010 +0100
+++ b/lisp/ChangeLog	Thu Sep 16 16:46:27 2010 +0100
@@ -1,3 +1,13 @@
+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.
+
 2010-09-16  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* info.el (Info-insert-dir):
--- a/lisp/behavior.el	Thu Sep 16 15:58:10 2010 +0100
+++ b/lisp/behavior.el	Thu Sep 16 16:46:27 2010 +0100
@@ -349,15 +349,11 @@
   (let ((result
 	 (completing-read
 	  prompt
-	  (let ((table (let (lis)
-			 (maphash #'(lambda (key val)
-				      (push (cons key val) lis))
-				  behavior-hash-table)
-			 (nreverse lis))))
-	    (mapc #'(lambda (aentry)
-		      (setcar aentry (symbol-name (car aentry))))
-		  table)
-	    table)
+	  (let (list)
+	    (maphash #'(lambda (key value)
+			 (push (cons (symbol-name key) value) list))
+		     behavior-hash-table)
+	    list)
 	  nil must-match initial-contents (or history 'behavior-history)
 	  default-value)))
     (if (and result (stringp result))
--- a/lisp/hash-table.el	Thu Sep 16 15:58:10 2010 +0100
+++ b/lisp/hash-table.el	Thu Sep 16 16:46:27 2010 +0100
@@ -37,34 +37,27 @@
 
 (defun hash-table-key-list (hash-table)
   "Return a list of all keys in HASH-TABLE."
-  (let (lis)
-    (maphash #'(lambda (key val)
-		 (push key lis))
-	     hash-table)
-    (nreverse lis)))
+  (let (list)
+    (maphash #'(lambda (key value) (push key list)) hash-table)
+    list))
 
 (defun hash-table-value-list (hash-table)
   "Return a list of all values in HASH-TABLE."
-  (let (lis)
-    (maphash #'(lambda (key val)
-		 (push val lis))
-	     hash-table)
-    (nreverse lis)))
+  (let (list)
+    (maphash #'(lambda (key value) (push value list)) hash-table)
+    list))
 
 (defun hash-table-key-value-alist (hash-table)
   "Return an alist of (KEY . VALUE) for all keys and values in HASH-TABLE."
-  (let (lis)
-    (maphash #'(lambda (key val)
-		 (push (cons key val) lis))
+  (let (list)
+    (maphash #'(lambda (key value) (setq list (acons key value list)))
 	     hash-table)
-    (nreverse lis)))
+    list))
 
 (defun hash-table-key-value-plist (hash-table)
   "Return a plist for all keys and values in HASH-TABLE.
 A plist is a simple list containing alternating keys and values."
-  (let (lis)
-    (maphash #'(lambda (key val)
-		 (push key lis)
-		 (push val lis))
+  (let (list)
+    (maphash #'(lambda (key value) (setq list (list* key value list)))
 	     hash-table)
-    (nreverse lis)))
+    list))