Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits: b100ecd4 by Raymond Toy at 2023-07-27T17:59:17-07:00 Compute list length manual instead of calling length
For some strange reason, ansi-test `set-difference.error.11` fails in `lisp::list-to-hashtable` which uses `length` to compute the length of a list. Let's try computing the length manually ourselves.
- - - - -
1 changed file:
- src/code/list.lisp
Changes:
===================================== src/code/list.lisp ===================================== @@ -766,7 +766,11 @@ (return-from list-to-hashtable nil)) ;; If the list is too short, the hashtable makes things ;; slower. We also need to balance memory usage. - (let ((len (length list))) + (let ((len 0)) + ;; Compute list length ourselves. + (dolist (item list) + (declare (ignore item)) + (incf len)) (when (< len *min-list-length-for-hashtable*) (return-from list-to-hashtable nil)) (let ((hashtable (make-hash-table :test hash-test :size len)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b100ecd403f9ce701532d385...