]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify code using take, ntake and butlast
authorMattias Engdegård <mattiase@acm.org>
Fri, 12 Aug 2022 11:35:01 +0000 (13:35 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sun, 14 Aug 2022 13:43:12 +0000 (15:43 +0200)
* lisp/calc/calc-vec.el (calcFunc-rhead):
* lisp/calc/calc.el (calc-top-list, calc-pop):
* lisp/emacs-lisp/ert.el (ert-summarize-tests-batch-and-exit):
Simplify.

lisp/calc/calc-vec.el
lisp/calc/calc.el
lisp/emacs-lisp/ert.el
lisp/progmodes/gdb-mi.el

index 3b8629b797d7b8a263359164d1a654f22762fb6b..8d99f62a9bab1998ccb82e6e9be79b7ed5527a7f 100644 (file)
 (defun calcFunc-rhead (vec)
   (if (and (Math-vectorp vec)
           (cdr vec))
-      (let ((vec (copy-sequence vec)))
-       (setcdr (nthcdr (- (length vec) 2) vec) nil)
-       vec)
+      (butlast vec)
     (calc-record-why 'vectorp vec)
     (list 'calcFunc-rhead vec)))
 
index 254c703ee220ded1e0d667dfc5221b929add8941..6c21430b1b3f6c6b081dc03dc8c144395c0ee9db 100644 (file)
@@ -1959,12 +1959,8 @@ See calc-keypad for details."
   (or n (setq n 1))
   (or m (setq m 1))
   (calc-check-stack (+ n m -1))
-  (and (> n 0)
-       (let ((top (copy-sequence (nthcdr (+ m calc-stack-top -1)
-                                        calc-stack))))
-        (setcdr (nthcdr (1- n) top) nil)
-        (nreverse
-          (mapcar (lambda (x) (calc-get-stack-element x sel-mode)) top)))))
+  (nreverse (mapcar (lambda (x) (calc-get-stack-element x sel-mode))
+                    (take n (nthcdr (+ m calc-stack-top -1) calc-stack)))))
 
 (defun calc-top-list-n (&optional n m sel-mode)
   (mapcar #'math-check-complete
@@ -2291,9 +2287,7 @@ the United States."
              ((and (null n)
                    (eq (car-safe top) 'incomplete)
                    (> (length top) (if (eq (nth 1 top) 'intv) 3 2)))
-              (calc-pop-push-list 1 (let ((tt (copy-sequence top)))
-                                      (setcdr (nthcdr (- (length tt) 2) tt) nil)
-                                      (list tt))))
+              (calc-pop-push-list 1 (list (butlast top))))
              ((< nn 0)
               (if (and calc-any-selections
                        (calc-top-selected 1 (- nn)))
index c8ff6b68144fddb38dd3c45d6c783a5a06b55bf1..047b0069bb9d313a9bcb40e3d54cf5c95fab0396 100644 (file)
@@ -1813,8 +1813,7 @@ Ran \\([0-9]+\\) tests, \\([0-9]+\\) results as expected\
     (unless (or (null tests) (zerop high))
       (message "\nLONG-RUNNING TESTS")
       (message "------------------")
-      (setq tests (sort tests (lambda (x y) (> (car x) (car y)))))
-      (when (< high (length tests)) (setcdr (nthcdr (1- high) tests) nil))
+      (setq tests (ntake high (sort tests (lambda (x y) (> (car x) (car y))))))
       (message "%s" (mapconcat #'cdr tests "\n")))
     ;; More details on hydra and emba, where the logs are harder to get to.
     (when (and (or (getenv "EMACS_HYDRA_CI") (getenv "EMACS_EMBA_CI"))
index 6f67eff31a2dca10866fbed4cc86e5d913ecae72..c256198b3c1540c9129b8fdefb58164e562dabfe 100644 (file)
@@ -2512,9 +2512,8 @@ means to decode using the coding-system set for the GDB process."
   ;; Record transactions if logging is enabled.
   (when gdb-enable-debug
     (push (cons 'recv string) gdb-debug-log)
-    (if (and gdb-debug-log-max
-            (> (length gdb-debug-log) gdb-debug-log-max))
-       (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil)))
+    (when gdb-debug-log-max
+      (setq gdb-debug-log (ntake gdb-debug-log-max gdb-debug-log))))
 
   ;; Recall the left over gud-marker-acc from last time.
   (setq gud-marker-acc (concat gud-marker-acc string))