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

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

[elpa] externals/dash 84721fc 206/316: Optimize -repeat a bit


From: ELPA Syncer
Subject: [elpa] externals/dash 84721fc 206/316: Optimize -repeat a bit
Date: Mon, 15 Feb 2021 15:58:01 -0500 (EST)

branch: externals/dash
commit 84721fc466d7546556e1978a308d27ca99cad36c
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Optimize -repeat a bit
    
    * dash.el (-repeat): Use make-list.
    * README.md (Other list operations):
    * dash.texi (Other list operations): Regenerate docs.
---
 README.md | 2 +-
 dash.el   | 6 ++----
 dash.texi | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 10508fa..5b3ee0e 100644
--- a/README.md
+++ b/README.md
@@ -1688,7 +1688,7 @@ The time complexity is `o`(n).
 
 #### -repeat `(n x)`
 
-Return a list with `x` repeated `n` times.
+Return a new list of length `n` with each element being `x`.
 Return nil if `n` is less than 1.
 
 ```el
diff --git a/dash.el b/dash.el
index 08a5cf9..840e704 100644
--- a/dash.el
+++ b/dash.el
@@ -2473,12 +2473,10 @@ not, return a list with ARGS as elements."
     (if (listp arg) arg args)))
 
 (defun -repeat (n x)
-  "Return a list with X repeated N times.
+  "Return a new list of length N with each element being X.
 Return nil if N is less than 1."
   (declare (pure t) (side-effect-free t))
-  (let (ret)
-    (--dotimes n (!cons x ret))
-    ret))
+  (and (natnump n) (make-list n x)))
 
 (defun -sum (list)
   "Return the sum of LIST."
diff --git a/dash.texi b/dash.texi
index b8274d1..65e8061 100644
--- a/dash.texi
+++ b/dash.texi
@@ -2537,7 +2537,7 @@ The time complexity is @var{o}(n).
 
 @anchor{-repeat}
 @defun -repeat (n x)
-Return a list with @var{x} repeated @var{n} times.
+Return a new list of length @var{n} with each element being @var{x}.
 Return nil if @var{n} is less than 1.
 
 @example



reply via email to

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