1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-23 22:20:24 -08:00

Repair and speed up safe-copy-tree and make it internal (bug#61962)

There is no particular requirement for safe-copy-tree so let's make it
internal for now.  The new implementation is faster and more correct.

* doc/lispref/lists.texi (Building Lists):
* etc/NEWS:  Remove doc and announcement.
* lisp/subr.el (safe-copy-tree--seen, safe-copy-tree--1)
(safe-copy-tree): Remove old version.
* lisp/emacs-lisp/bytecomp.el (bytecomp--copy-tree-seen)
(bytecomp--copy-tree-1, bytecomp--copy-tree): Add new version.
(byte-compile-initial-macro-environment): Use it.
* test/lisp/subr-tests.el (subr--safe-copy-tree):
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--copy-tree):
Move and improve tests.
This commit is contained in:
Mattias Engdegård 2023-03-12 17:00:25 +01:00
parent f5f13495f5
commit 75f04848a6
6 changed files with 65 additions and 100 deletions

View file

@ -1850,6 +1850,34 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode python-mode)) \
(should (eq (byte-compile-file src-file) 'no-byte-compile))
(should-not (file-exists-p dest-file))))
(ert-deftest bytecomp--copy-tree ()
(should (null (bytecomp--copy-tree nil)))
(let ((print-circle t))
(let* ((x '(1 2 (3 4)))
(y (bytecomp--copy-tree x)))
(should (equal (prin1-to-string (list x y))
"((1 2 (3 4)) (1 2 (3 4)))")))
(let* ((x '#1=(a #1#))
(y (bytecomp--copy-tree x)))
(should (equal (prin1-to-string (list x y))
"(#1=(a #1#) #2=(a #2#))")))
(let* ((x '#1=(#1# a))
(y (bytecomp--copy-tree x)))
(should (equal (prin1-to-string (list x y))
"(#1=(#1# a) #2=(#2# a))")))
(let* ((x '((a . #1=(b)) #1#))
(y (bytecomp--copy-tree x)))
(should (equal (prin1-to-string (list x y))
"(((a . #1=(b)) #1#) ((a . #2=(b)) #2#))")))
(let* ((x '#1=(a #2=(#1# b . #3=(#2# c . #1#)) (#3# d)))
(y (bytecomp--copy-tree x)))
(should (equal (prin1-to-string (list x y))
(concat
"("
"#1=(a #2=(#1# b . #3=(#2# c . #1#)) (#3# d))"
" "
"#4=(a #5=(#4# b . #6=(#5# c . #4#)) (#6# d))"
")"))))))
;; Local Variables:
;; no-byte-compile: t