From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string' Date: Thu, 26 Nov 2020 15:03:30 +0100 Message-ID: <87zh34p64t.fsf@gnus.org> References: <6F768DED-2E1B-4D06-A776-FFA162AC32AD@acm.org> <97535AF5-D542-4267-A5A9-1483C32A61AC@acm.org> <83EC926B-DE9E-48BC-8FD2-C7CB3617AD50@acm.org> <871rggs1mk.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33390"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Shigeru Fukaya , 44861-done@debbugs.gnu.org, Stefan Kangas , Dmitry Gutov To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 26 15:04:38 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 1kiHsy-0008Vy-M3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Nov 2020 15:04:36 +0100 Original-Received: from localhost ([::1]:47606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kiHsx-0006mx-8F for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Nov 2020 09:04:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiHsT-0006l1-9x for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 09:04:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kiHsP-0007y3-Lk for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 09:04:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kiHsP-0005eg-IG for bug-gnu-emacs@gnu.org; Thu, 26 Nov 2020 09:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Nov 2020 14:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44861 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch confirmed Original-Received: via spool by 44861-done@debbugs.gnu.org id=D44861.160639942321712 (code D ref 44861); Thu, 26 Nov 2020 14:04:01 +0000 Original-Received: (at 44861-done) by debbugs.gnu.org; 26 Nov 2020 14:03:43 +0000 Original-Received: from localhost ([127.0.0.1]:40338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiHs6-0005e8-KZ for submit@debbugs.gnu.org; Thu, 26 Nov 2020 09:03:42 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:50850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kiHs5-0005du-08 for 44861-done@debbugs.gnu.org; Thu, 26 Nov 2020 09:03:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RqMNGeuHtY0Scs8J/YM6lfVAOfAQM0rtPzWlln31aOU=; b=uTZq2ugfPNDvZwT0nJaFvaM3xP hNjlKZ+f3Tbf3s4N6T8dYK46F71+IQ/c/q1OtliAhqP9u4XvPEg/NyTX9zozH3lDu8L2qcdwLEifP hbhcUpzJeuCqd0hZhDgL0dzTpm/kTLubcZJDsq6f3c0hfGpuGtyHyzvmdR0wtnizmYdo=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kiHrv-0002DX-MP; Thu, 26 Nov 2020 15:03:34 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEXW0sqJgHMmJST/ //8NscnUAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+QLGg03OyChr50AAAF6SURBVCjPRZHBTuMwEIZ/ R3FEc2KlBlGfYSX6FO4KOKeotrQ5bxHkKbrSqmezUnPgFFCK8DwlM25TRoqcb/7MzB8PkKIGlnKe 8VO4WyiBKRznXfpA33lXm72FYs4kX9Ie98QKq8oQxYYsqgVQEQ2eIis1ZjsiCopqKOtdyRDROujK oSX6oP2zRT7Ni6YjCZk51cZWrwm4da6htVRJtAEPkahPhuh+VazX7S4p1PBgFyfy7iie89ELVE1c s9dsk7PJztPqt8VEVO081UWwf6SiuvH0fxGykGDX0IC6tAK+M/QJXKYh5b+frCBPSrFaUmDzh/s7 38x7NcLSGnZiD7BA2fU4hkX5FnCKi74ea9jjW/2tKP6F1Qh5i+sfp7Kn/CrbHZvjBk+/tiPM+8/i /QTD0Axjx/nLYGI1wvbF8KquE5htKCnoR5lpTfeXV2RbcRPMx63nu56JspmTbmSTcj9o48QftoVn FWk2Qsxia457VJSyCZSUUpSd7r8ADi2IHHCSwcQAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjAtMTEt MjZUMTM6NTU6NTgrMDA6MDD1AI5yAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIwLTExLTI2VDEzOjU1 OjU4KzAwOjAwhF02zgAAAABJRU5ErkJggg== X-Now-Playing: Liaisons Dangereuses's _Liaisons Dangereuses_: "Dupont" In-Reply-To: ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Thu, 26 Nov 2020 14:39:01 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:194323 Archived-At: Mattias Engdeg=C3=A5rd writes: > Probably, but that would be a pure performance improvement. Most of > the time is currently consumed in primitives (string-match, > replace-match, substring, concat) so don't expect huge savings unless > a substantially different approach is taken. Yeah, perhaps there's isn't a lot to be gained there, unless a lot of the re-checking of all the arguments (etc.) (which is unnecessary once we've ascertained that everything is, indeed, a string) can be done by refactoring some of the underlying primitives. > (Dmitry Gutov asked for a C implementation in bug#20273 for improving > the speed of json encoding; is that still relevant?) No, probably not, since it's now done by Jansson? So I'm closing that one. > A bigger saving yet would be to use the much faster string-replace > wherever possible. A little sweeping refactoring project perhaps? It > would also improve readability -- no regexp quoting, fewer mysterious > arguments like LITERAL and FIXEDCASE to worry about, etc. I started looking at that, and there's a huge pile of calls like (replace-regexp-in-string ":" ";" string) that can be rewritten to use string-replace. But! Every single case requires careful analysis, exactly because replace-regexp-in-string sets the match data. Perhaps five lines later, there's a reference to (match-string 0 string)? Perhaps the reference is in the function that called this function? So most changes are fraught with possible unforeseen breakages, the code is super-duper straightforward like (setq string (replace-regexp-in-string ":" ";" string)) (setq string (replace-regexp-in-string "a" "b" string)) Then you know that you can replace the first one without any danger. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no