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

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

[elpa] externals/compat 4bd1226048 59/84: Rewrite take to copy only as m


From: ELPA Syncer
Subject: [elpa] externals/compat 4bd1226048 59/84: Rewrite take to copy only as much as required
Date: Tue, 3 Jan 2023 08:57:36 -0500 (EST)

branch: externals/compat
commit 4bd12260483fde4e8d06d12e2986befb302fad44
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Rewrite take to copy only as much as required
---
 compat-29.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/compat-29.el b/compat-29.el
index a492fe1001..64aa3a78d7 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -106,7 +106,11 @@ Otherwise, return LIST after truncating it."
   "Return the first N elements of LIST.
 If N is zero or negative, return nil.
 If N is greater or equal to the length of LIST, return LIST (or a copy)."
-  (compat--ntake-elisp n (copy-sequence list)))      ;FIXME: only copy as much 
as necessary
+  (let (copy)
+    (while (and (< 0 n) list)
+      (push (pop list) copy)
+      (setq n (1- n)))
+    (nreverse copy)))
 
 (compat-defun string-equal-ignore-case (string1 string2)
   "Like `string-equal', but case-insensitive.



reply via email to

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