From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#40407: [PATCH] slow ENCODE_FILE and DECODE_FILE Date: Sat, 4 Apr 2020 18:41:39 +0200 Message-ID: <729DE2D1-EA0F-46F9-8B4B-2ED146CE6892@acm.org> References: <805F9723-8298-4FD7-A47B-1E683721A5B0@acm.org> <835zegwn9y.fsf@gnu.org> <83mu7rvbyk.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_9B9AC2A3-5983-46DF-AE16-BAACF6DF753B" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="76530"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 40407@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 04 18:42:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jKls4-000Jml-Bv for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Apr 2020 18:42:12 +0200 Original-Received: from localhost ([::1]:40460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKls3-0001N9-D4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Apr 2020 12:42:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56417) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKlrv-0001N2-J1 for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2020 12:42:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jKlru-0007JH-K3 for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2020 12:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jKlru-0007J3-81 for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2020 12:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jKlru-0000Kw-65 for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2020 12:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Apr 2020 16:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40407 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 40407-submit@debbugs.gnu.org id=B40407.15860185131257 (code B ref 40407); Sat, 04 Apr 2020 16:42:02 +0000 Original-Received: (at 40407) by debbugs.gnu.org; 4 Apr 2020 16:41:53 +0000 Original-Received: from localhost ([127.0.0.1]:44659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jKlrk-0000KA-Pl for submit@debbugs.gnu.org; Sat, 04 Apr 2020 12:41:53 -0400 Original-Received: from mail1459c50.megamailservers.eu ([91.136.14.59]:40852 helo=mail267c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jKlrh-0000Jd-NZ for 40407@debbugs.gnu.org; Sat, 04 Apr 2020 12:41:50 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1586018502; bh=AN8rfhemmHefjybxTqE89KrzMh+7EErEXtB2qGwC480=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=mH9TeUhEXGY4gocX9O9aky1o6316rgboekFaW52a9DNY0EuiHqh4jHILm0i1JKNSA 2ly6XjTOv/H4CSI3nJ3SE/S7RI655RiMWpJmBGxjh2OpirrmbOVbuarWF6YrGRQe2D jULrQEQ8QDakqi/Dzida+2gt13lPMT3Fzb2xcICU= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail267c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 034GfesK028093; Sat, 4 Apr 2020 16:41:42 +0000 In-Reply-To: <83mu7rvbyk.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F20.5E88B887.009F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=Cf92G4jl c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=zcUfEPlord_Q0e7CtzMA:9 a=CjuIK1q_8ugA:10 a=bdXfzROkdeKqxy9yWSUA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178029 Archived-At: --Apple-Mail=_9B9AC2A3-5983-46DF-AE16-BAACF6DF753B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 4 apr. 2020 kl. 11.26 skrev Eli Zaretskii : > DECODE_FILE is called because the file name in question starts with a > "~"? Otherwise, I don't think I understand why would expand-file-name > need to decode a file name. Maybe it's because default-directory started with a tilde. It doesn't = really matter; it's a common case, and the profiler tells us as much. > IME, the cases where we can safely assume it's OK to return the same > string are actually very rare. It is no accident that you saw so few > calls of these functions where we use that optional behavior. This does not mean that the remaining 179 calls require a copy; they = just use the default value of the parameter. > Neither, IMO. Again, it's a separate problem, and let's keep our > sights squarely on the original issue you wanted to fix. Let's tackle > the NOCOPY issue in a separate discussion, OK? Thank you, a separate bug for it is fine. Here is a revised patch which takes the nocopy parameter into account = (in its inverted sense). Obviously it needs to be adapted if the nocopy = inversion is dealt with first; the two bugs do not commute. --Apple-Mail=_9B9AC2A3-5983-46DF-AE16-BAACF6DF753B Content-Disposition: attachment; filename=0001-Avoid-expensive-recoding-for-ASCII-identity-cases-bu.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Avoid-expensive-recoding-for-ASCII-identity-cases-bu.patch" Content-Transfer-Encoding: quoted-printable =46rom=200c6139ab490733f3c1257665535fc4ed2ad0dbe7=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=203=20Apr=202020=2016:01:01=20+0200=0A= Subject:=20[PATCH]=20Avoid=20expensive=20recoding=20for=20ASCII=20= identity=20cases=20(bug#40407)=0A=0AOptimise=20for=20the=20common=20case=20= of=20encoding=20or=20decoding=20an=20ASCII-only=0Astring=20using=20an=20= ASCII-compatible=20coding,=20for=20file=20names=20in=20particular.=0A=0A= *=20src/coding.c=20(string_ascii_p):=20New=20function.=0A= (code_convert_string):=20Return=20the=20input=20string=20for=20= ASCII-only=20inputs=0Aand=20ASCII-compatible=20codings.=0A---=0A=20= src/coding.c=20|=2023=20++++++++++++++++++++++-=0A=201=20file=20changed,=20= 22=20insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20a/src/coding.c=20= b/src/coding.c=0Aindex=200bea2a0c2b..0fdbc95939=20100644=0A---=20= a/src/coding.c=0A+++=20b/src/coding.c=0A@@=20-9471,6=20+9471,17=20@@=20= used=20(which=20may=20be=20different=20from=20CODING-SYSTEM=20if=20= CODING-SYSTEM=20is=0A=20=20=20return=20code_convert_region=20(start,=20= end,=20coding_system,=20destination,=201,=200);=0A=20}=0A=20=0A+/*=20= Whether=20a=20(unibyte)=20string=20only=20contains=20chars=20in=20the=20= 0..127=20range.=20=20*/=0A+static=20bool=0A+string_ascii_p=20= (Lisp_Object=20str)=0A+{=0A+=20=20ptrdiff_t=20nbytes=20=3D=20SBYTES=20= (str);=0A+=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20nbytes;=20i++)=0A= +=20=20=20=20if=20(SREF=20(str,=20i)=20>=20127)=0A+=20=20=20=20=20=20= return=20false;=0A+=20=20return=20true;=0A+}=0A+=0A=20Lisp_Object=0A=20= code_convert_string=20(Lisp_Object=20string,=20Lisp_Object=20= coding_system,=0A=20=09=09=20=20=20=20=20Lisp_Object=20dst_object,=20= bool=20encodep,=20bool=20nocopy,=0A@@=20-9502,7=20+9513,17=20@@=20= code_convert_string=20(Lisp_Object=20string,=20Lisp_Object=20= coding_system,=0A=20=20=20chars=20=3D=20SCHARS=20(string);=0A=20=20=20= bytes=20=3D=20SBYTES=20(string);=0A=20=0A-=20=20if=20(BUFFERP=20= (dst_object))=0A+=20=20if=20(EQ=20(dst_object,=20Qt))=0A+=20=20=20=20{=0A= +=20=20=20=20=20=20/*=20Fast=20path=20for=20ASCII-only=20input=20and=20= an=20ASCII-compatible=20coding:=0A+=20=20=20=20=20=20=20=20=20act=20as=20= identity.=20=20*/=0A+=20=20=20=20=20=20Lisp_Object=20attrs=20=3D=20= CODING_ID_ATTRS=20(coding.id);=0A+=20=20=20=20=20=20if=20(!=20NILP=20= (CODING_ATTR_ASCII_COMPAT=20(attrs))=0A+=20=20=20=20=20=20=20=20=20=20&&=20= (STRING_MULTIBYTE=20(string)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ?=20(chars=20=3D=3D=20bytes)=20:=20string_ascii_p=20(string)))=0A+=09= return=20nocopy=20?=20Fcopy_sequence=20(string)=20:=20string;=0A+=20=20=20= =20}=0A+=20=20else=20if=20(BUFFERP=20(dst_object))=0A=20=20=20=20=20{=0A=20= =20=20=20=20=20=20struct=20buffer=20*buf=20=3D=20XBUFFER=20(dst_object);=0A= =20=20=20=20=20=20=20ptrdiff_t=20buf_pt=20=3D=20BUF_PT=20(buf);=0A--=20=0A= 2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_9B9AC2A3-5983-46DF-AE16-BAACF6DF753B--