From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#7174: 23.2; `last' can be made faster by using `length' Date: Wed, 13 Oct 2010 18:48:56 -0400 Message-ID: References: <874ocxbhbx.wl%irieshinsuke@yahoo.co.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1287011551 20903 80.91.229.12 (13 Oct 2010 23:12:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 13 Oct 2010 23:12:31 +0000 (UTC) Cc: 7174@debbugs.gnu.org To: Juanma Barranquero Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 14 01:12:29 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P6AUn-0005IX-2s for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Oct 2010 01:12:29 +0200 Original-Received: from localhost ([127.0.0.1]:52849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6AUm-0006Rt-7Q for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Oct 2010 19:12:28 -0400 Original-Received: from [140.186.70.92] (port=39068 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6AUb-0006PK-Ld for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2010 19:12:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P6AUa-0006cv-Q1 for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2010 19:12:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P6AUa-0006cm-Oc for bug-gnu-emacs@gnu.org; Wed, 13 Oct 2010 19:12:16 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P6A5B-0007WF-Ny; Wed, 13 Oct 2010 18:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Oct 2010 22:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7174 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 7174-submit@debbugs.gnu.org id=B7174.128700993128890 (code B ref 7174); Wed, 13 Oct 2010 22:46:01 +0000 Original-Received: (at 7174) by debbugs.gnu.org; 13 Oct 2010 22:45:31 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P6A4f-0007Vv-T2 for submit@debbugs.gnu.org; Wed, 13 Oct 2010 18:45:30 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P6A4d-0007Vq-Mo for 7174@debbugs.gnu.org; Wed, 13 Oct 2010 18:45:28 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1P6A80-0005is-Bl; Wed, 13 Oct 2010 18:48:56 -0400 X-Spook: LABLINK Hamas CISU Medco world domination encryption SHA X-Ran: cI!YTi/#DiS<\aA:r|egv>T.U3'VfhT/ft`V4_wyYpz X-Hue: blue X-Attribution: GM In-Reply-To: (Juanma Barranquero's message of "Thu\, 14 Oct 2010 00\:25\:18 +0200") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 13 Oct 2010 18:46:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40865 Archived-At: Juanma Barranquero wrote: > They are not equivalent: > > (last '(1 . 2) 0) => 2 > (last-new '(1 . 2) 0) => nil See also http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7206 (defun last-new2 (list &optional n) "Return the last link of LIST. Its car is the last element. If LIST is nil, return nil. 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 (and (>= n 0) (let ((m (safe-length list))) (if (< n m) (nthcdr (- m n) list) list))) (and list (nthcdr (1- (safe-length list)) list)))) (last-new2 '(1 . 2) 0) => 2