From unknown Wed Jun 25 09:07:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#17814 <17814@debbugs.gnu.org> To: bug#17814 <17814@debbugs.gnu.org> Subject: Status: 24.3.91; better string manipulation in subr-x Reply-To: bug#17814 <17814@debbugs.gnu.org> Date: Wed, 25 Jun 2025 16:07:31 +0000 retitle 17814 24.3.91; better string manipulation in subr-x reassign 17814 emacs submitter 17814 Shigeru Fukaya severity 17814 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 15:11:12 2014 Received: (at submit) by debbugs.gnu.org; 19 Jun 2014 19:11:12 +0000 Received: from localhost ([127.0.0.1]:53461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wxhjs-0007mW-3b for submit@debbugs.gnu.org; Thu, 19 Jun 2014 15:11:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39735) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wxhjp-0007mF-Mf for submit@debbugs.gnu.org; Thu, 19 Jun 2014 15:11:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wxhjb-0005AR-8s for submit@debbugs.gnu.org; Thu, 19 Jun 2014 15:11:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,FREEMAIL_FROM, FSL_HELO_FAKE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wxhjb-0005AH-70 for submit@debbugs.gnu.org; Thu, 19 Jun 2014 15:10:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxhjS-0000bY-4o for bug-gnu-emacs@gnu.org; Thu, 19 Jun 2014 15:10:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxhjG-00057O-EW for bug-gnu-emacs@gnu.org; Thu, 19 Jun 2014 15:10:46 -0400 Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]:62055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxhjG-00057H-5x for bug-gnu-emacs@gnu.org; Thu, 19 Jun 2014 15:10:34 -0400 Received: by mail-pd0-f175.google.com with SMTP id v10so2116307pde.34 for ; Thu, 19 Jun 2014 12:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:mime-version:content-type:message-id; bh=MfOjwrhjkTVER754IzBt9yhAxDkaPXok5m102Ga5qvk=; b=NjZoSlDq+bAr4llfPwpw8RhRO9tvmmJRgs+9TKW+/Txh9+KwCdXWRR/BmFHeo5oKYa i1kwSMOaZDLBSYguMmpURarbLwNwNCCPUM80abZRwEV1Vt2qiNpH+v9Jv14RBDpXGGMK MiSJMCepPIMdbmq660gcaY8hWClCW3zNdpJmZc0xY7zCuGX4jNEG1D/I+NbYJlZky2Y+ 8OZW29pO22e/DJ3iS5/IcFIJNDbjV/Fh89fwVPN3tkDfk3z/OHOCOttkfwUz77zAOKCD 4tiZEZvLBc69VxTd8+wK53zFWIgvZl8CqP6lDsJHHdLOgQAf4ri+MlQ8cQLLLxn3C61D sGNw== X-Received: by 10.68.203.132 with SMTP id kq4mr8223181pbc.12.1403205033108; Thu, 19 Jun 2014 12:10:33 -0700 (PDT) Received: from gmail.com (115x125x38x6.ap115.ftth.ucom.ne.jp. [115.125.38.6]) by mx.google.com with ESMTPSA id qq5sm9831577pbb.24.2014.06.19.12.10.30 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jun 2014 12:10:31 -0700 (PDT) From: Shigeru Fukaya To: bug-gnu-emacs@gnu.org Subject: 24.3.91; better string manipulation in subr-x Date: Fri, 20 Jun 2014 04:10:30 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-OmSFN4okCh9b6j4fuESNa" X-Mailer: HidemaruMail 6.24 (WinNT,602) Message-Id: <38CF8BF2232E16shigeru.fukaya@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --Boundary-OmSFN4okCh9b6j4fuESNa Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Some string manipulation functions in subr-x have room to optimize. string-trim-left, string-trim-right -- use `substring' and `match-beginning/end' instead of `replace-match'. The formers have bytecodes and the latter not. string-trim -- call string-trim-left first would be cost effective. But, to change the code to trim both sides of the string at once might be better. string-remove-suffix -- change the last argument of substring will shorten the code. I change the string-trim defined using defun from defsubst, as its string literal is somewhat big (Actually I suspect most of other functions would also be better if defined by defun). Regards, Shigeru --Boundary-OmSFN4okCh9b6j4fuESNa Content-Type: application/octet-stream; name="subr-x.diff" Content-Disposition: attachment; filename="subr-x.diff" Content-Transfer-Encoding: base64 LS0tIG9yaWcvc3Vici14LmVsCTIwMTQtMDMtMjEgMTQ6MzQ6NDAuMDAwMDAwMDAwICswOTAw CisrKyAuL3N1YnIteC5lbAkyMDE0LTA2LTIwIDAzOjQzOjU0LjYyNzM5MDcwMCArMDkwMApA QCAtNTksMTggKzU5LDIzIEBACiAoZGVmc3Vic3Qgc3RyaW5nLXRyaW0tbGVmdCAoc3RyaW5n KQogICAiUmVtb3ZlIGxlYWRpbmcgd2hpdGVzcGFjZSBmcm9tIFNUUklORy4iCiAgIChpZiAo c3RyaW5nLW1hdGNoICJcXGBbIFx0XG5ccl0rIiBzdHJpbmcpCi0gICAgICAocmVwbGFjZS1t YXRjaCAiIiB0IHQgc3RyaW5nKQorICAgICAgKHN1YnN0cmluZyBzdHJpbmcgKG1hdGNoLWVu ZCAwKSkKICAgICBzdHJpbmcpKQogCiAoZGVmc3Vic3Qgc3RyaW5nLXRyaW0tcmlnaHQgKHN0 cmluZykKICAgIlJlbW92ZSB0cmFpbGluZyB3aGl0ZXNwYWNlIGZyb20gU1RSSU5HLiIKICAg KGlmIChzdHJpbmctbWF0Y2ggIlsgXHRcblxyXStcXCciIHN0cmluZykKLSAgICAgIChyZXBs YWNlLW1hdGNoICIiIHQgdCBzdHJpbmcpCisgICAgICAoc3Vic3RyaW5nIHN0cmluZyAwICht YXRjaC1iZWdpbm5pbmcgMCkpCiAgICAgc3RyaW5nKSkKIAotKGRlZnN1YnN0IHN0cmluZy10 cmltIChzdHJpbmcpCisoZGVmdW4gc3RyaW5nLXRyaW0gKHN0cmluZykKICAgIlJlbW92ZSBs ZWFkaW5nIGFuZCB0cmFpbGluZyB3aGl0ZXNwYWNlIGZyb20gU1RSSU5HLiIKLSAgKHN0cmlu Zy10cmltLWxlZnQgKHN0cmluZy10cmltLXJpZ2h0IHN0cmluZykpKQorICA7OyhzdHJpbmct dHJpbS1yaWdodCAoc3RyaW5nLXRyaW0tbGVmdCBzdHJpbmcpKQorICAoaWYgKHN0cmluZy1t YXRjaCAoY29uY2F0ICJcXGBcXCg/Oltcc1x0XG5ccl0rXFwoPzE6Lio/XFwpW1xzXHRcblxy XSoiCisJCQkgICAgIlxcfFxcKD8xOi4qP1xcKVtcc1x0XG5ccl0rXFwpXFwnIikKKwkJICAg IHN0cmluZykKKyAgICAgIChtYXRjaC1zdHJpbmcgMSBzdHJpbmcpCisgICAgc3RyaW5nKSkK IAogKGRlZnN1YnN0IHN0cmluZy1ibGFuay1wIChzdHJpbmcpCiAgICJDaGVjayB3aGV0aGVy IFNUUklORyBpcyBlaXRoZXIgZW1wdHkgb3Igb25seSB3aGl0ZXNwYWNlLiIKQEAgLTg1LDcg KzkwLDcgQEAKIChkZWZzdWJzdCBzdHJpbmctcmVtb3ZlLXN1ZmZpeCAoc3VmZml4IHN0cmlu ZykKICAgIlJlbW92ZSBTVUZGSVggZnJvbSBTVFJJTkcgaWYgcHJlc2VudC4iCiAgIChpZiAo c3RyaW5nLXN1ZmZpeC1wIHN1ZmZpeCBzdHJpbmcpCi0gICAgICAoc3Vic3RyaW5nIHN0cmlu ZyAwICgtIChsZW5ndGggc3RyaW5nKSAobGVuZ3RoIHN1ZmZpeCkpKQorICAgICAgKHN1YnN0 cmluZyBzdHJpbmcgMCAoLSAobGVuZ3RoIHN1ZmZpeCkpKQogICAgIHN0cmluZykpCiAKIChw cm92aWRlICdzdWJyLXgpCg== --Boundary-OmSFN4okCh9b6j4fuESNa-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 16:44:22 2014 Received: (at 17814) by debbugs.gnu.org; 19 Jun 2014 20:44:22 +0000 Received: from localhost ([127.0.0.1]:53496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxjC2-0001gl-CP for submit@debbugs.gnu.org; Thu, 19 Jun 2014 16:44:22 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:9311) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WxjC0-0001gR-AX for 17814@debbugs.gnu.org; Thu, 19 Jun 2014 16:44:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYGAIDvNVNLd+D9/2dsb2JhbABZgwaDSr0vgw6BFxd0giUBAQEBAgFWIwULCzQSFBgNJIgECNIZF456B4Q4BKkZgWqDTCE X-IPAS-Result: ArYGAIDvNVNLd+D9/2dsb2JhbABZgwaDSr0vgw6BFxd0giUBAQEBAgFWIwULCzQSFBgNJIgECNIZF456B4Q4BKkZgWqDTCE X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="68413258" Received: from 75-119-224-253.dsl.teksavvy.com (HELO pastel.home) ([75.119.224.253]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 19 Jun 2014 16:44:13 -0400 Received: by pastel.home (Postfix, from userid 20848) id CBC7660D16; Thu, 19 Jun 2014 16:44:12 -0400 (EDT) From: Stefan Monnier To: Shigeru Fukaya Subject: Re: bug#17814: 24.3.91; better string manipulation in subr-x Message-ID: References: <38CF8BF2232E16shigeru.fukaya@gmail.com> Date: Thu, 19 Jun 2014 16:44:12 -0400 In-Reply-To: <38CF8BF2232E16shigeru.fukaya@gmail.com> (Shigeru Fukaya's message of "Fri, 20 Jun 2014 04:10:30 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 17814 Cc: 17814@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > I change the string-trim defined using defun from defsubst, as its > string literal is somewhat big (Actually I suspect most of other > functions would also be better if defined by defun). The use of `defsubst' is so that subr-x.el is not needed at run-time. Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 20 13:14:41 2014 Received: (at 17814) by debbugs.gnu.org; 20 Jun 2014 17:14:41 +0000 Received: from localhost ([127.0.0.1]:55017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wy2Oa-0007nX-J4 for submit@debbugs.gnu.org; Fri, 20 Jun 2014 13:14:41 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:38220) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wy2OS-0007n2-Gm for 17814@debbugs.gnu.org; Fri, 20 Jun 2014 13:14:33 -0400 Received: by mail-pa0-f54.google.com with SMTP id et14so3320379pad.41 for <17814@debbugs.gnu.org>; Fri, 20 Jun 2014 10:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:mime-version:content-type :content-transfer-encoding:in-reply-to:references:message-id; bh=3usT8yBJU7VvA89sy3s9hWwM2+QSARmNRDfbAJtPRqM=; b=NNbXXnveoWJ1jljPNz2ahI/wezKFsnDw66hdUhqzhRPDQU8Y9EYYGm5ajczy0DBAcK 6JknYE046gBgb7wUm/9pFsZ2cAgASyKWdu3SVCvGKAL8dvgN/QRAfM3V8sF2jftwxfOK 8bYG437QxOEEgszTCtHGfgHGNf1MToGWDhaq/rsLFwK3NEzuq4dGhS8frzuIJoD2V1Zs lf6AQ01FMVtnUnYheJDmsuy8SFpafkL767POM6x2SP3qsESoXxYPA5srj/vBN1KTggj8 Ipoe7+7GiSeQezGs1pCMZI3NNUrUO8C/e5rtO1R60YKNxbvPOIxrp/a7O9XpS16ncs6t 4sFw== X-Received: by 10.66.232.166 with SMTP id tp6mr6443817pac.127.1403284461860; Fri, 20 Jun 2014 10:14:21 -0700 (PDT) Received: from gmail.com (115x125x38x6.ap115.ftth.ucom.ne.jp. [115.125.38.6]) by mx.google.com with ESMTPSA id ee5sm14386306pbc.47.2014.06.20.10.14.18 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jun 2014 10:14:19 -0700 (PDT) From: Shigeru Fukaya To: Stefan Monnier , 17814@debbugs.gnu.org Subject: Re: bug#17814: 24.3.91; better string manipulation in subr-x Date: Sat, 21 Jun 2014 02:14:19 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: HidemaruMail 6.24 (WinNT,602) In-Reply-To: References: <38CF8BF2232E16shigeru.fukaya@gmail.com> Message-Id: <39CF8CAB123C5Fshigeru.fukaya@gmail.com> X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 17814 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >> I change the string-trim defined using defun from defsubst, as its >> string literal is somewhat big (Actually I suspect most of other >> functions would also be better if defined by defun). > >The use of `defsubst' is so that subr-x.el is not needed at run-time. I see. I didn't know that, and it's very good. Then, the code is (defsubst string-trim (string) "Remove leading and trailing whitespace from STRING." (string-trim-right (string-trim-left string))) or (defsubst string-trim (string) "Remove leading and trailing whitespace from STRING." (string-match "\\`[\s\t\n\r]*\\(.*?\\)[\s\t\n\r]*\\'" string) (if (or (< 0 (match-beginning 1)) (< (match-end 1) (match-end 0))) (match-string 1 string) string)) The latter is shorter in byte-compiled code, and call string-match only once. Literal string is seemingly larger, but the overhead of a string object will cover it, I think. Regards, Shigeru From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 20 15:15:00 2014 Received: (at 17814) by debbugs.gnu.org; 20 Jun 2014 19:15:00 +0000 Received: from localhost ([127.0.0.1]:55112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wy4H4-0005vc-VQ for submit@debbugs.gnu.org; Fri, 20 Jun 2014 15:14:59 -0400 Received: from relais.videotron.ca ([24.201.245.36]:46151) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wy4H1-0005vQ-Vf for 17814@debbugs.gnu.org; Fri, 20 Jun 2014 15:14:56 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from ceviche.home ([24.203.184.39]) by VL-VM-MR001.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0N7H00HVBESV4YT1@VL-VM-MR001.ip.videotron.ca> for 17814@debbugs.gnu.org; Fri, 20 Jun 2014 15:14:55 -0400 (EDT) Received: by ceviche.home (Postfix, from userid 20848) id A03E3660FA; Fri, 20 Jun 2014 15:14:56 -0400 (EDT) From: Stefan Monnier To: Shigeru Fukaya Subject: Re: bug#17814: 24.3.91; better string manipulation in subr-x Message-id: References: <38CF8BF2232E16shigeru.fukaya@gmail.com> <39CF8CAB123C5Fshigeru.fukaya@gmail.com> Date: Fri, 20 Jun 2014 15:14:56 -0400 In-reply-to: <39CF8CAB123C5Fshigeru.fukaya@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 17814 Cc: 17814@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > (string-match "\\`[\s\t\n\r]*\\(.*?\\)[\s\t\n\r]*\\'" string) > (if (or (< 0 (match-beginning 1)) (< (match-end 1) (match-end 0))) > (match-string 1 string) > string)) The above string-match will fail on a string that has a newline, and the subsequent code will use whatever was the old match-data, resulting in broken behavior. Other than that, I don't have any opinion on such changes (I've never heard anyone complain about code size or cpu-time of any of those functions, so I think it largely doesn't matter either way). Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 21 00:07:38 2014 Received: (at 17814) by debbugs.gnu.org; 21 Jun 2014 04:07:38 +0000 Received: from localhost ([127.0.0.1]:55337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WyCaX-0002N8-SV for submit@debbugs.gnu.org; Sat, 21 Jun 2014 00:07:38 -0400 Received: from mail-pb0-f48.google.com ([209.85.160.48]:55134) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WyCaV-0002Mq-IV for 17814@debbugs.gnu.org; Sat, 21 Jun 2014 00:07:36 -0400 Received: by mail-pb0-f48.google.com with SMTP id rq2so3776188pbb.7 for <17814@debbugs.gnu.org>; Fri, 20 Jun 2014 21:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:mime-version:content-type :content-transfer-encoding:in-reply-to:references:message-id; bh=DTVjFk25lArhIoOk7nbdid5eQrDhk8CnYOu3cor/FJw=; b=mfwKsdtztg7wyMuZ2E9ixJn/Yks9vP/M1YcGNtmiLA3urpAroZbDzAqELt9Ng7imVk mmcJXA5+r5ym4ZSqtZ7reDQuQslEun3wgpVhM3rTCAUIcCExE3+7trrjfceGxiuhfXHi NCKM+Wd18UMD5fNmjsLZqoWwwIbcq62sWFOCkF6A6hW79omKpmL/cq/rcP0s9SP5gq1o 1D9dmcfl80KhIwQE6V0DXEYKtv4ojrb6L4UhmquSIXHfO/PMvWT/0Xo5bf4bO8lct3g3 3DCd+u5GCypt471gseU8qYRICgoCe0YYeVZ6u0hTKBAAFY+9j3wwjJgJyWqtwkrMnEO6 eFRw== X-Received: by 10.66.150.228 with SMTP id ul4mr10173099pab.16.1403323649506; Fri, 20 Jun 2014 21:07:29 -0700 (PDT) Received: from gmail.com (115x125x38x6.ap115.ftth.ucom.ne.jp. [115.125.38.6]) by mx.google.com with ESMTPSA id cj1sm53073465pac.40.2014.06.20.21.07.27 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jun 2014 21:07:28 -0700 (PDT) From: Shigeru Fukaya To: Stefan Monnier Subject: Re: bug#17814: 24.3.91; better string manipulation in subr-x Date: Sat, 21 Jun 2014 13:07:27 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: HidemaruMail 6.24 (WinNT,602) In-Reply-To: References: <38CF8BF2232E16shigeru.fukaya@gmail.com> <39CF8CAB123C5Fshigeru.fukaya@gmail.com> Message-Id: <3CCF8D06508F70shigeru.fukaya@gmail.com> X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 17814 Cc: 17814@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >The above string-match will fail on a string that has a newline, and the >subsequent code will use whatever was the old match-data, resulting in >broken behavior. "." in "\\`[\s\t\n\r]*\\(.*?\\)[\s\t\n\r]*\\'" must be "\\(.\\|\n\\)", sorry. >Other than that, I don't have any opinion on such changes (I've never >heard anyone complain about code size or cpu-time of any of those >functions, so I think it largely doesn't matter either way). Using string-trim-to-right and string-trim-to-left creates unnecessary temporary string if both sides need triming may matter, then? Anyway, I think I'm just sending a small proposal. I don't care much if you throw it away. Thank you for spending your time. Regards, Shigeru t From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 18 21:37:30 2018 Received: (at 17814) by debbugs.gnu.org; 19 Sep 2018 01:37:30 +0000 Received: from localhost ([127.0.0.1]:44920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g2RQo-00033O-FH for submit@debbugs.gnu.org; Tue, 18 Sep 2018 21:37:30 -0400 Received: from mail-it0-f46.google.com ([209.85.214.46]:37713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g2RQl-000334-Rf; Tue, 18 Sep 2018 21:37:28 -0400 Received: by mail-it0-f46.google.com with SMTP id h20-v6so5673082itf.2; Tue, 18 Sep 2018 18:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Kc7+rMKu5Ygvb3ARA+KL8WtvPy08f4lnYTaA3W4fBYw=; b=HkO3o0+aiDWVdHWk9wncFhdVXLs5q5D4FqKb17/UP31cXDyQP4+UobiSQ2Y8VOMreE 03IA5tHCAhCACsTTHzjZT6xvwfiN6fdAjrvg5v6lQ+L07+pYYjaAID6jXt7iLbYWTs6o +lITD7P4Ozt7kuiAeG79ahENVUZ4vUa265dB+vO7z3hxphLoKTsD8/u8gqI2Px3POk8Z jstUwQa8WsA0EQTRQYRBIyHap7vUQ5XX3zM5sjYPrQleWjPdJFg5C+Xqm6Cf3hibqIKl isBYX8ZOv4dMyj3IddoGdy1mfkaKR4QIoy88ryiFif0eHDWQEOr1KTnPiaoLt3K1n5s4 zZLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=Kc7+rMKu5Ygvb3ARA+KL8WtvPy08f4lnYTaA3W4fBYw=; b=KKN82zNvuF3YwRZcm+VhkCdF5DSuwYvotWE/7w9hI5wlLerccRRo69gK+kcKcmFwzh ow0qaYwqnxo36glfjF2oSxo1HZlzK+luzdbnaC5Gqa+QSafFeDASm0kpW19zbAegO0ZZ ofBRq7k4P8guZdoUMfR0gaNZQ+34pD4lZ69fohx/N3Zs3tpVgaHH0VeZ1Yqol2J8Q+zY o6IhvORFEV5082W2lG6HiKbY4KVtrm+yEeyrNSA3PHNf307/xnavgpF1X25cewHiF1He yd5C5zVrq9rq5HfXldPS3i3aIqBBEe8FN5j0Ux83r0dZnxIkuq328nWCYsK9ozMpHAnc nr0Q== X-Gm-Message-State: APzg51CeXKdtdLyvW01D4xp9mqO/u0LsxQ5rFuIdnfTMqL44StByEqQe zHcEOHHgpe1CoolCghuH39rugpIq X-Google-Smtp-Source: ANB0VdZKzVFb515CUOBkbCNxzeT8McdUtppPx68ZVNbn75LUy+VQURX87e+20c20GAsHVsN9GF9gyg== X-Received: by 2002:a24:29cf:: with SMTP id p198-v6mr19320321itp.48.1537321042082; Tue, 18 Sep 2018 18:37:22 -0700 (PDT) Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id b3-v6sm4908547itj.32.2018.09.18.18.37.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Sep 2018 18:37:21 -0700 (PDT) From: Noam Postavsky To: Shigeru Fukaya Subject: Re: bug#17814: 24.3.91; better string manipulation in subr-x References: <38CF8BF2232E16shigeru.fukaya@gmail.com> <39CF8CAB123C5Fshigeru.fukaya@gmail.com> <3CCF8D06508F70shigeru.fukaya@gmail.com> Date: Tue, 18 Sep 2018 21:37:20 -0400 In-Reply-To: <3CCF8D06508F70shigeru.fukaya@gmail.com> (Shigeru Fukaya's message of "Sat, 21 Jun 2014 13:07:27 +0900") Message-ID: <87va72p8rz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 17814 Cc: 17814@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 17814 quit Shigeru Fukaya writes: >>The above string-match will fail on a string that has a newline, and the >>subsequent code will use whatever was the old match-data, resulting in >>broken behavior. > > "." in "\\`[\s\t\n\r]*\\(.*?\\)[\s\t\n\r]*\\'" must be "\\(.\\|\n\\)", sorry. > >>Other than that, I don't have any opinion on such changes (I've never >>heard anyone complain about code size or cpu-time of any of those >>functions, so I think it largely doesn't matter either way). > > Using string-trim-to-right and string-trim-to-left creates unnecessary > temporary string if both sides need triming may matter, then? > > Anyway, I think I'm just sending a small proposal. I don't care much > if you throw it away. Thank you for spending your time. An optimization similar to the one proposed here was done for string-trim-to-{left,right} in [1: 1013e0392b]. I think the strim-trim change isn't worth the extra complexity (especially since it's not even entirely clear whether it would be faster/smaller), so I'm closing the bug. [1: 1013e0392b]: 2018-07-13 11:28:16 -0400 Tweak subr-x.el substring functions https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1013e0392b78ee0e2199fb51859dc9e939315f9b From unknown Wed Jun 25 09:07:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 17 Oct 2018 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator