master: Use COPY-SEQ in COPY-SSET
snuglas via Sbcl-commits <[email protected]> Sun, 05 Jul 2026 17:18:13 +0000
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via 41b8f562f4a3f7a49396f8702183c764c31ccfe6 (commit)
from c09560decb41b572bcc358e232726f7a37da7c46 (commit)
- Log -----------------------------------------------------------------
commit 41b8f562f4a3f7a49396f8702183c764c31ccfe6
Author: Douglas Katzman <[email protected]>
Date: Sun Jul 5 16:27:43 2026 +0000
Use COPY-SEQ in COPY-SSET
The remark that REPLACE lacked optimization was true in early 2007
when written and COPY-SEQ got a transform only in Dec 2007 (19efdada)
---
src/compiler/sset.lisp | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/compiler/sset.lisp b/src/compiler/sset.lisp
index bbc08ab2a..565e40c92 100644
--- a/src/compiler/sset.lisp
+++ b/src/compiler/sset.lisp
@@ -28,11 +28,10 @@
(number nil :type (or index null)))
(defstruct (sset (:copier nil)
- (:constructor make-sset (&optional vector free count)))
+ (:constructor %make-sset (vector free count)))
;; Vector containing the set values. 0 is used for empty (since
;; initializing a vector with 0 is cheaper than with NIL), -1
- ;; is used to mark buckets that used to contain an element, but no
- ;; longer do.
+ ;; is a tombstone left in place of a deleted element.
(vector #() :type simple-vector)
;; How many elements can be inserted before rehashing.
;; This is not the actual amount of free elements, but a ratio
@@ -40,6 +39,9 @@
(free 0 :type index)
;; How many elements are currently members of the set.
(count 0 :type index))
+(defun make-sset ()
+ (declare (inline %make-sset))
+ (%make-sset #() 0 0))
(declaim (freeze-type sset))
@@ -167,17 +169,7 @@
;;; Return a new copy of SET.
(declaim (ftype (sfunction (sset) sset) copy-sset))
(defun copy-sset (set)
- (make-sset (let* ((vector (sset-vector set))
- (new-vector (make-array (length vector))))
- (declare (type simple-vector vector new-vector)
- (optimize speed (safety 0)))
- ;; There's no REPLACE deftransform for simple-vectors.
- (dotimes (i (length vector))
- (setf (aref new-vector i)
- (aref vector i)))
- new-vector)
- (sset-free set)
- (sset-count set)))
+ (%make-sset (copy-seq (sset-vector set)) (sset-free set) (sset-count set)))
;;; Perform the appropriate set operation on SET1 and SET2 by
;;; destructively modifying SET1. We return true if SET1 was modified,
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL