diff options
| author | Mattias EngdegÄrd | 2024-04-29 20:24:07 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-04-29 22:16:08 +0200 |
| commit | 3000edc6179dfe0b5f24ae2e472826530809dfd1 (patch) | |
| tree | 278ba4939b4210aff5c3666c1cc994a78e75efb1 | |
| parent | 97a2710554fbd10a0c866e890f507e391620e769 (diff) | |
| download | emacs-3000edc6179dfe0b5f24ae2e472826530809dfd1.tar.gz emacs-3000edc6179dfe0b5f24ae2e472826530809dfd1.zip | |
Use the nthcdr byte-op for drop, and raise open-code limit
* lisp/emacs-lisp/byte-opt.el (byte-optimize-nthcdr):
Open-code for any integral N<5. Always use the byte-op otherwise.
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 3d6b35422b8..4095726d276 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -1512,13 +1512,15 @@ See Info node `(elisp) Integer Basics'." | |||
| 1512 | (put 'nthcdr 'byte-optimizer #'byte-optimize-nthcdr) | 1512 | (put 'nthcdr 'byte-optimizer #'byte-optimize-nthcdr) |
| 1513 | (defun byte-optimize-nthcdr (form) | 1513 | (defun byte-optimize-nthcdr (form) |
| 1514 | (if (= (safe-length form) 3) | 1514 | (if (= (safe-length form) 3) |
| 1515 | (if (memq (nth 1 form) '(0 1 2)) | 1515 | (let ((count (nth 1 form))) |
| 1516 | (let ((count (nth 1 form))) | 1516 | (cond ((and (integerp count) (<= count 3)) |
| 1517 | (setq form (nth 2 form)) | 1517 | (setq form (nth 2 form)) |
| 1518 | (while (>= (setq count (1- count)) 0) | 1518 | (while (>= (setq count (1- count)) 0) |
| 1519 | (setq form (list 'cdr form))) | 1519 | (setq form (list 'cdr form))) |
| 1520 | form) | 1520 | form) |
| 1521 | form) | 1521 | ((not (eq (car form) 'nthcdr)) |
| 1522 | (cons 'nthcdr (cdr form))) ; use the nthcdr byte-op | ||
| 1523 | (t form))) | ||
| 1522 | form)) | 1524 | form)) |
| 1523 | 1525 | ||
| 1524 | (put 'cons 'byte-optimizer #'byte-optimize-cons) | 1526 | (put 'cons 'byte-optimizer #'byte-optimize-cons) |