0.8.0.78.vector-nil-string.3:
[sbcl.git] / src / compiler / generic / vm-tran.lisp
index 7c4cc00..3298c81 100644 (file)
 \f
 ;;;; simplifying HAIRY-DATA-VECTOR-REF and HAIRY-DATA-VECTOR-SET
 
+(deftransform hairy-data-vector-ref ((string index) (simple-string t))
+  (let ((ctype (continuation-type string)))
+    (if (array-type-p ctype)
+       ;; the other transform will kick in, so that's OK
+       (give-up-ir1-transform)
+       `(typecase string
+         ((simple-array character (*)) (data-vector-ref string index))
+         ((simple-array nil (*)) (data-vector-ref string index))))))
+
 (deftransform hairy-data-vector-ref ((array index) (array t) * :important t)
   "avoid runtime dispatch on array element type"
   (let ((element-ctype (extract-upgraded-element-type array)))
                          index
                          new-value)))))
 
+(deftransform hairy-data-vector-set ((string index new-value)
+                                    (simple-string t t))
+  (let ((ctype (continuation-type string)))
+    (if (array-type-p ctype)
+       ;; the other transform will kick in, so that's OK
+       (give-up-ir1-transform)
+       `(typecase string
+         ((simple-array character (*))
+          (data-vector-set string index new-value))
+         ((simple-array nil (*))
+          (data-vector-set string index new-value))))))
+
 (deftransform data-vector-set ((array index new-value)
                                (simple-array t t))
   (let ((array-type (continuation-type array)))
       (memmove (sap+ (sapify dst) dst-start)
               (sap+ (sapify src) src-start)
               (- dst-end dst-start)))
-     nil))
+     (values)))
 \f
 ;;;; transforms for EQL of floating point values