From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Returning argument string (regexp-quote) Date: Tue, 24 Sep 2019 13:28:15 +0200 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_D66DF664-17A1-47D3-A001-7E604E142F8E" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="99543"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 24 13:29:11 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iCj0I-000PnZ-Ow for ged-emacs-devel@m.gmane.org; Tue, 24 Sep 2019 13:29:10 +0200 Original-Received: from localhost ([::1]:44148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCj0H-0001Dv-I7 for ged-emacs-devel@m.gmane.org; Tue, 24 Sep 2019 07:29:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41851) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCizW-0001Dl-N2 for emacs-devel@gnu.org; Tue, 24 Sep 2019 07:28:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCizV-0004FI-BH for emacs-devel@gnu.org; Tue, 24 Sep 2019 07:28:22 -0400 Original-Received: from mail177c50.megamailservers.eu ([91.136.10.187]:39984 helo=mail51c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCizU-0004Bx-Pk for emacs-devel@gnu.org; Tue, 24 Sep 2019 07:28:21 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1569324497; bh=k7UoOTJB+YNY1e+fni1iPUtyjvNAyjHVgxLGVm14Rl4=; h=From:Subject:Date:To:From; b=GpXI5TLOEwGSpFbaf09Is2rw2jcSqiBD0x3BY9eIuKuCGAf86Ic0jUOk/39DXOVII Psfrp7Y77Wre1fIkTiAWnB3wiKvbt+9/0hN6up+ibQJt3ps2QSwIdnFqj+1iebijH5 a4uxRzRN4Jd1o7CDNgTcQMnJNNktujoXLFjQZ0lw= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail51c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x8OBSG7X001520 for ; Tue, 24 Sep 2019 11:28:17 +0000 X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0205.5D89FDD1.005A, 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=GNR27dFK c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=u5aWS9ZNdrnANWL4JTMA:9 a=CjuIK1q_8ugA:10 a=3d-OsxnqrACJS7xNgy0A:9 a=B2y7HmGcmWMA:10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 91.136.10.187 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240274 Archived-At: --Apple-Mail=_D66DF664-17A1-47D3-A001-7E604E142F8E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii In most calls to 'regexp-quote', the argument doesn't actually need = converting. It would be nice to avoid the allocation in that case. = Patch. More generally, do we need to preserve allocation for functions not = specifically documented to return new strings? I can imagine there being = code that depend on it by accident, but string mutation is rare. --Apple-Mail=_D66DF664-17A1-47D3-A001-7E604E142F8E Content-Disposition: attachment; filename=0001-Allow-regexp-quote-to-return-its-argument.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Allow-regexp-quote-to-return-its-argument.patch" Content-Transfer-Encoding: quoted-printable =46rom=2030b34719db89f6094346e9dd4004509674e7021c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=2023=20Sep=202019=2018:56:30=20+0200=0A= Subject:=20[PATCH]=20Allow=20regexp-quote=20to=20return=20its=20argument=0A= =0A*=20src/search.c=20(Fregexp_quote):=20Only=20allocate=20a=20new=20= string=20if=20needed.=0A---=0A=20src/search.c=20|=2010=20++++++----=0A=20= 1=20file=20changed,=206=20insertions(+),=204=20deletions(-)=0A=0Adiff=20= --git=20a/src/search.c=20b/src/search.c=0Aindex=201e57d2ecbe..fc9b85f413=20= 100644=0A---=20a/src/search.c=0A+++=20b/src/search.c=0A@@=20-3138,10=20= +3138,12=20@@=20DEFUN=20("regexp-quote",=20Fregexp_quote,=20= Sregexp_quote,=201,=201,=200,=0A=20=20=20=20=20}=0A=20=0A=20=20=20= Lisp_Object=20result=0A-=20=20=20=20=3D=20make_specified_string=20(temp,=0A= -=09=09=09=20=20=20=20=20SCHARS=20(string)=20+=20backslashes_added,=0A-=09= =09=09=20=20=20=20=20out=20-=20temp,=0A-=09=09=09=20=20=20=20=20= STRING_MULTIBYTE=20(string));=0A+=20=20=20=20=3D=20(out=20-=20temp=20>=20= SBYTES=20(string)=0A+=20=20=20=20=20=20=20?=20make_specified_string=20= (temp,=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20SCHARS=20(string)=20+=20= backslashes_added,=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20out=20-=20temp,=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20STRING_MULTIBYTE=20(string))=0A+=20=20=20=20=20=20=20:=20= string);=0A=20=20=20SAFE_FREE=20();=0A=20=20=20return=20result;=0A=20}=0A= --=20=0A2.21.0=20(Apple=20Git-122)=0A=0A= --Apple-Mail=_D66DF664-17A1-47D3-A001-7E604E142F8E--