From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Shmakov Newsgroups: gmane.emacs.bugs Subject: bug#18175: files.el: use mapc in (mapcar 'switch-to-buffer ...) Date: Sun, 03 Aug 2014 08:55:21 +0000 Message-ID: <87mwbmeyva.fsf@violet.siamics.net> References: <87r40yftes.fsf@violet.siamics.net> <3d8bb179-4e59-4d81-9ee1-54ff0da430b0@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1407056198 15546 80.91.229.3 (3 Aug 2014 08:56:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 3 Aug 2014 08:56:38 +0000 (UTC) To: 18175@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 03 10:56:28 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XDrae-0004Eq-Ik for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Aug 2014 10:56:28 +0200 Original-Received: from localhost ([::1]:47283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDrae-0005jw-25 for geb-bug-gnu-emacs@m.gmane.org; Sun, 03 Aug 2014 04:56:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDraJ-0005Oc-Bl for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 04:56:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDraF-0007f3-75 for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 04:56:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDraE-0007ev-Kz for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 04:56:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XDraE-0005Vn-2w for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2014 04:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Shmakov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Aug 2014 08:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18175 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18175-submit@debbugs.gnu.org id=B18175.140705613421148 (code B ref 18175); Sun, 03 Aug 2014 08:56:02 +0000 Original-Received: (at 18175) by debbugs.gnu.org; 3 Aug 2014 08:55:34 +0000 Original-Received: from localhost ([127.0.0.1]:55589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XDrZm-0005V1-1T for submit@debbugs.gnu.org; Sun, 03 Aug 2014 04:55:34 -0400 Original-Received: from fely.am-1.org ([78.47.74.50]:49217) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XDrZj-0005Uq-AR for 18175@debbugs.gnu.org; Sun, 03 Aug 2014 04:55:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net; s=a2013295; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:Sender:References:Subject:To:From; bh=5dOgHudPOrDZLLd2e6PfSfsw9ctOw6EtIYGJcN5iJ3U=; b=Ph/MDTtsKcv1AW/D2hvuxzUxpozZ3jl17uUY7iWh4fEiTF/bmAntLy/5xCinX2rhbhfsDKkHaKaUrD4iVAadn/K5TQ25zcXyS0xPh92lL9KNI4Eo2HIOPVkVSwT5DOcHiFgB0WZgneeuweGHdunEstzNTKcko83dMuXZ1ot89B0=; Original-Received: from [2a02:2560:6d4:26ca::1:1d] (helo=violet.siamics.net) by fely.am-1.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XDrZh-0003ZR-Ah for 18175@debbugs.gnu.org; Sun, 03 Aug 2014 08:55:29 +0000 Original-Received: from localhost ([::1] helo=violet.siamics.net) by violet.siamics.net with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XDrZa-0007LN-3T for 18175@debbugs.gnu.org; Sun, 03 Aug 2014 15:55:22 +0700 In-Reply-To: <3d8bb179-4e59-4d81-9ee1-54ff0da430b0@default> (Drew Adams's message of "Sat, 2 Aug 2014 17:55:53 -0700 (PDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92070 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> Drew Adams writes: >> Given that switch-to-buffer returns its argument, /and/ given that >> mapc returns the sequence it=E2=80=99s given, I suggest that the >> (mapcar 'switch-to-buffer LIST) forms in lisp/files.el be replaced >> with (mapc 'switch-to-buffer LIST), =E2=80=93 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 =E2=80=9Cfresh=E2=80=9D on= es 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). How do you signal that the values returned by the argument function are unimportant, /and/ that you=E2=80=99re interested in the /original/ list instead? > If you want to improve the performance, and that is the only change > you want to make, then please consider another approach. Please consider the patch MIMEd. FWIW, it avoids one more cons in both find-file-other-window and find-file-other-frame. --=20 FSF associate member #7257 http://boycottsystemd.org/ =E2=80=A6 3013 B6A0= 230E 334A --=-=-= Content-Type: text/x-diff Content-Disposition: inline diff --git a/lisp/files.el b/lisp/files.el index 9272e98..c3a6f0d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1428,7 +1428,7 @@ automatically choosing a major mode, use \\[find-file-literally]." (confirm-nonexistent-file-or-buffer))) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) - (mapcar 'switch-to-buffer (nreverse value)) + (mapc 'switch-to-buffer (nreverse value)) (switch-to-buffer value)))) (defun find-file-other-window (filename &optional wildcards) @@ -1448,10 +1448,10 @@ expand wildcards (if any) and visit multiple files." (confirm-nonexistent-file-or-buffer))) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) - (progn - (setq value (nreverse value)) - (cons (switch-to-buffer-other-window (car value)) - (mapcar 'switch-to-buffer (cdr value)))) + (prog1 + (setq value (nreverse value)) + (switch-to-buffer-other-window (car value)) + (mapc 'switch-to-buffer (cdr value))) (switch-to-buffer-other-window value)))) (defun find-file-other-frame (filename &optional wildcards) @@ -1471,10 +1471,10 @@ expand wildcards (if any) and visit multiple files." (confirm-nonexistent-file-or-buffer))) (let ((value (find-file-noselect filename nil nil wildcards))) (if (listp value) - (progn - (setq value (nreverse value)) - (cons (switch-to-buffer-other-frame (car value)) - (mapcar 'switch-to-buffer (cdr value)))) + (prog1 + (setq value (nreverse value)) + (switch-to-buffer-other-frame (car value)) + (mapc 'switch-to-buffer (cdr value))) (switch-to-buffer-other-frame value)))) (defun find-file-existing (filename) --=-=-=--