GNU bug report logs - #18175
files.el: use mapc in (mapcar 'switch-to-buffer ...)

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Sat, 2 Aug 2014 21:56:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 25.1

Done: Ivan Shmakov <ivan <at> siamics.net>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 18175 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Ivan Shmakov <ivan <at> siamics.net>, 18175 <at> debbugs.gnu.org
Subject: RE: bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...)
Date: Sat, 2 Aug 2014 17:55:53 -0700 (PDT)
> 	Given that switch-to-buffer returns its argument, /and/ given
> 	that mapc returns the sequence it’s given, I suggest that the
> 	(mapcar 'switch-to-buffer LIST) forms in lisp/files.el be
> 	replaced with (mapc 'switch-to-buffer LIST), – if only to avoid
> 	the unnecessary consing when the list is effectively copied in
> 	the mapcar case.
> 
> 	The lists mapcar is applied to in such cases are returned from
> 	find-file-noselect, and so, as it seems, are “fresh” ones
> 	anyway.

Not a good idea, IMHO.

It's not just about performance; it's about coding style.

By using `mapcar' you are signaling that you are interested in the return values of the argument function (and of course the resulting list of them).

By using `mapc' you are signaling that the values returned by the argument function are unimportant (only its side effects are significant).

If you want to improve the performance, and that is the only change you want to make, then please consider another approach.




This bug report was last modified 10 years and 179 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.