unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28856: Replace gnus-last-element with car->last
@ 2017-10-16  4:07 Eric Abrahamsen
  0 siblings, 0 replies; only message in thread
From: Eric Abrahamsen @ 2017-10-16  4:07 UTC (permalink / raw)
  To: 28856

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

(car (last LIST)) does just what (gnus-last-element LIST) does, and is
considerably more efficient.

I think this is fairly uncontroversial, but will let it hang out a bit
first in case anyone sees something I don't.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-gnus-last-element.patch --]
[-- Type: text/x-diff, Size: 2503 bytes --]

From 63251a3248569df0fde85f52e3ce1f605e0c3b3a Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
Date: Tue, 9 May 2017 18:48:00 +0800
Subject: [PATCH] Remove gnus-last-element

* lisp/gnus/gnus-range.el: Now better expressed as (car (last LIST)).
* lisp/gnus/gnus-cache.el (gnus-cache-generate-active):
* lisp/gnus/gnus-sum.el (gnus-select-newsgroup,
  gnus-summary-insert-articles): Replace calls.
---
 lisp/gnus/gnus-cache.el | 2 +-
 lisp/gnus/gnus-range.el | 6 ------
 lisp/gnus/gnus-sum.el   | 4 ++--
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el
index 12c8903d02..801728d2f2 100644
--- a/lisp/gnus/gnus-cache.el
+++ b/lisp/gnus/gnus-cache.el
@@ -735,7 +735,7 @@ gnus-cache-generate-active
       ;; `gnus-cache-unified-group-names' needless.
       (gnus-sethash (or (cdr (assoc group gnus-cache-unified-group-names))
 			group)
-		    (cons (car nums) (gnus-last-element nums))
+		    (cons (car nums) (car (last nums)))
 		    gnus-cache-active-hashtb))
     ;; Go through all the other files.
     (dolist (file alphs)
diff --git a/lisp/gnus/gnus-range.el b/lisp/gnus/gnus-range.el
index b30b2e9099..3c84f9d69a 100644
--- a/lisp/gnus/gnus-range.el
+++ b/lisp/gnus/gnus-range.el
@@ -33,12 +33,6 @@ gnus-range-normalize
 If RANGE is a single range, return (RANGE). Otherwise, return RANGE."
   (if (listp (cdr-safe range)) range (list range)))
 
-(defun gnus-last-element (list)
-  "Return last element of LIST."
-  (while (cdr list)
-    (setq list (cdr list)))
-  (car list))
-
 (defun gnus-copy-sequence (list)
   "Do a complete, total copy of a list."
   (let (out)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 48571096cc..22160e4142 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -5737,7 +5737,7 @@ gnus-select-newsgroup
 	      (mail-header-number (car gnus-newsgroup-headers))
 	      gnus-newsgroup-end
 	      (mail-header-number
-	       (gnus-last-element gnus-newsgroup-headers))))
+	       (car (last gnus-newsgroup-headers)))))
       ;; GROUP is successfully selected.
       (or gnus-newsgroup-headers t)))))
 
@@ -12915,7 +12915,7 @@ gnus-summary-insert-articles
 	    (mail-header-number (car gnus-newsgroup-headers))
 	    gnus-newsgroup-end
 	    (mail-header-number
-	     (gnus-last-element gnus-newsgroup-headers))))
+	     (car (last gnus-newsgroup-headers)))))
     (when gnus-use-scoring
       (gnus-possibly-score-headers))))
 
-- 
2.14.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-16  4:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16  4:07 bug#28856: Replace gnus-last-element with car->last Eric Abrahamsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).