emacs-diffs
[Top][All Lists]
Advanced

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

master d8d582dc3c: ; * lisp/emacs-lisp/subr-x.el (string-pad): Optimise.


From: Mattias Engdegård
Subject: master d8d582dc3c: ; * lisp/emacs-lisp/subr-x.el (string-pad): Optimise.
Date: Wed, 10 Aug 2022 07:09:43 -0400 (EDT)

branch: master
commit d8d582dc3c30e184e6f849eb302d0c89be019c83
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    ; * lisp/emacs-lisp/subr-x.el (string-pad): Optimise.
---
 lisp/emacs-lisp/subr-x.el | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index b7083bfe7c..1cce97cdb1 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -254,13 +254,9 @@ the string."
   (unless (natnump length)
     (signal 'wrong-type-argument (list 'natnump length)))
   (let ((pad-length (- length (length string))))
-    (if (< pad-length 0)
-        string
-      (concat (and start
-                   (make-string pad-length (or padding ?\s)))
-              string
-              (and (not start)
-                   (make-string pad-length (or padding ?\s)))))))
+    (cond ((<= pad-length 0) string)
+          (start (concat (make-string pad-length (or padding ?\s)) string))
+          (t (concat string (make-string pad-length (or padding ?\s)))))))
 
 (defun string-chop-newline (string)
   "Remove the final newline (if any) from STRING."



reply via email to

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