Commit f2a504a1 authored by Stas Boukarev's avatar Stas Boukarev
Browse files

Slightly optimize copy-mem by aligning the buffer.

parent 7234a088
......@@ -8,12 +8,14 @@
(defconstant +buffer-size+ 8192)
(deftype word () 'sb-vm:word)
(deftype signed-word () 'sb-vm:signed-word)
(defun allocate-buffer ()
(sb-sys:sap-int
(sb-alien:alien-sap
(sb-alien:make-alien char (+ +buffer-size+ 3)))))
(sb-alien:make-alien char
;; alignment
(+ +buffer-size+
(1- sb-vm:n-word-bytes))))))
(defstruct (input-stream
(:predicate nil))
......@@ -215,15 +217,9 @@
(declaim (inline copy-mem))
(defun copy-mem (from to length)
(declare (word length))
(let ((words-end (sb-ext:truly-the word
(- length
(rem length sb-vm:n-word-bytes)))))
(loop for i fixnum by sb-vm:n-word-bytes below words-end
do (setf (sb-sys:sap-ref-word to i)
(sb-sys:sap-ref-word from i)))
(loop for i fixnum from words-end below length
do (setf (sb-sys:sap-ref-8 to i)
(sb-sys:sap-ref-8 from i)))))
(loop for i fixnum by sb-vm:n-word-bytes to length
do (setf (sb-sys:sap-ref-word to i)
(sb-sys:sap-ref-word from i))))
(declaim (inline read-ascii-string-optimized))
(defun read-ascii-string-optimized (length string stream)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment