[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 93549c2b28: Avoid using if-let in subr.el
From: |
Lars Ingebrigtsen |
Subject: |
master 93549c2b28: Avoid using if-let in subr.el |
Date: |
Sat, 30 Apr 2022 10:25:21 -0400 (EDT) |
branch: master
commit 93549c2b28770a84e1d1b9478a0861e2050df602
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Avoid using if-let in subr.el
* lisp/subr.el (string-lines): Avoid using if-let (from subr-x) in
subr (bug#55194).
---
lisp/subr.el | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 14cab04d42..5fadac6e16 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6654,27 +6654,30 @@ lines."
(let ((lines nil)
(start 0))
(while (< start (length string))
- (if-let ((newline (string-search "\n" string start)))
- (progn
- (when (or (not omit-nulls)
- (not (= start newline)))
- (let ((line (substring string start
- (if keep-newlines
- (1+ newline)
- newline))))
- (when (not (and keep-newlines omit-nulls
- (equal line "\n")))
- (push line lines))))
- (setq start (1+ newline))
- ;; Include the final newline.
- (when (and (= start (length string))
- (not omit-nulls)
- (not keep-newlines))
- (push "" lines)))
- (if (zerop start)
- (push string lines)
- (push (substring string start) lines))
- (setq start (length string))))
+ (let ((newline (string-search "\n" string start)))
+ (if newline
+ (progn
+ (when (or (not omit-nulls)
+ (not (= start newline)))
+ (let ((line (substring string start
+ (if keep-newlines
+ (1+ newline)
+ newline))))
+ (when (not (and keep-newlines omit-nulls
+ (equal line "\n")))
+ (push line lines))))
+ (setq start (1+ newline))
+ ;; Include the final newline.
+ (when (and (= start (length string))
+ (not omit-nulls)
+ (not keep-newlines))
+ (push "" lines)))
+ ;; No newline in the remaining part.
+ (if (zerop start)
+ ;; Avoid a string copy if there are no newlines at all.
+ (push string lines)
+ (push (substring string start) lines))
+ (setq start (length string)))))
(nreverse lines)))
(defun buffer-match-p (condition buffer-or-name &optional arg)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 93549c2b28: Avoid using if-let in subr.el,
Lars Ingebrigtsen <=