]> git.eshelyaron.com Git - emacs.git/commitdiff
Make string-chop-newline more efficient
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Dec 2020 22:18:05 +0000 (23:18 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Dec 2020 22:18:05 +0000 (23:18 +0100)
* lisp/emacs-lisp/subr-x.el (string-chop-newline): Make more
efficient.

lisp/emacs-lisp/subr-x.el

index 4d1a73a251a433b81d8e9d8ec27369f5cf981a4b..1c8e1d6293f391a3c1b82115e67419cd49978c5a 100644 (file)
@@ -341,7 +341,7 @@ string."
 
 (defun string-chop-newline (string)
   "Remove the final newline (if any) from STRING."
-  (replace-regexp-in-string "\n\\'" "" string))
+  (string-remove-suffix "\n" string))
 
 (defun replace-region-contents (beg end replace-fn
                                     &optional max-secs max-costs)