emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r101946: * lisp/subr.el (last): Make


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r101946: * lisp/subr.el (last): Make it faster.
Date: Tue, 12 Oct 2010 20:30:36 -0700
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 101946
author: IRIE Shinsuke <address@hidden>
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2010-10-12 20:30:36 -0700
message:
  * lisp/subr.el (last): Make it faster.
modified:
  lisp/ChangeLog
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-13 03:23:47 +0000
+++ b/lisp/ChangeLog    2010-10-13 03:30:36 +0000
@@ -1,3 +1,7 @@
+2010-10-13  IRIE Shinsuke  <address@hidden>  (tiny change)
+
+       * subr.el (last): Make it faster.  (Bug#7174)
+
 2010-10-13  Rainer Orth  <address@hidden>  (tiny change)
 
        * Makefile.in (compile-clean): Use `` instead of $().  (Bug#7178)

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2010-10-03 21:23:13 +0000
+++ b/lisp/subr.el      2010-10-13 03:30:36 +0000
@@ -289,14 +289,11 @@
 If N is non-nil, return the Nth-to-last link of LIST.
 If N is bigger than the length of LIST, return LIST."
   (if n
-      (let ((m 0) (p list))
-       (while (consp p)
-         (setq m (1+ m) p (cdr p)))
-       (if (<= n 0) p
-         (if (< n m) (nthcdr (- m n) list) list)))
-    (while (consp (cdr list))
-      (setq list (cdr list)))
-    list))
+      (and (> n 0)
+           (let ((m (length list)))
+             (if (< n m) (nthcdr (- m n) list) list)))
+    (and list
+         (nthcdr (1- (length list)) list))))
 
 (defun butlast (list &optional n)
   "Return a copy of LIST with the last N elements removed."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]