emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/substitute 73a1904ea4 24/39: Do not check for fn in 'wh


From: ELPA Syncer
Subject: [elpa] externals/substitute 73a1904ea4 24/39: Do not check for fn in 'while' loop
Date: Mon, 16 Jan 2023 11:58:51 -0500 (EST)

branch: externals/substitute
commit 73a1904ea4521f9bf149f658950b6ed7252622c4
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Do not check for fn in 'while' loop
    
    We only want to perform the test once, not per iteration.
---
 substitute.el | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/substitute.el b/substitute.el
index 51014e1d64..b3023e21d4 100644
--- a/substitute.el
+++ b/substitute.el
@@ -163,14 +163,12 @@ Pass to it the TARGET and SCOPE arguments."
 (defun substitute--operate (target sub &optional scope)
   "Substitute TARGET with SUB in SCOPE.
 This is the subroutine of `substitute-target' and related."
-  (let (count)
+  (let ((count)
+        (search-fn (if (eq scope 'above) 're-search-backward 
're-search-forward)))
     (save-excursion
       (save-restriction
         (substitute--setup-scope target scope)
-        (while (funcall (if (eq scope 'above)
-                            're-search-backward
-                          're-search-forward)
-                        target nil t)
+        (while (funcall search-fn target nil t)
           (push (match-string-no-properties 0) count)
           (replace-match sub nil t))))
     (run-hook-with-args 'substitute-post-replace-hook



reply via email to

[Prev in Thread] Current Thread [Next in Thread]