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 @@ ...@@ -8,12 +8,14 @@
(defconstant +buffer-size+ 8192) (defconstant +buffer-size+ 8192)
(deftype word () 'sb-vm:word) (deftype word () 'sb-vm:word)
(deftype signed-word () 'sb-vm:signed-word)
(defun allocate-buffer () (defun allocate-buffer ()
(sb-sys:sap-int (sb-sys:sap-int
(sb-alien:alien-sap (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 (defstruct (input-stream
(:predicate nil)) (:predicate nil))
...@@ -215,15 +217,9 @@ ...@@ -215,15 +217,9 @@
(declaim (inline copy-mem)) (declaim (inline copy-mem))
(defun copy-mem (from to length) (defun copy-mem (from to length)
(declare (word length)) (declare (word length))
(let ((words-end (sb-ext:truly-the word (loop for i fixnum by sb-vm:n-word-bytes to length
(- length do (setf (sb-sys:sap-ref-word to i)
(rem length sb-vm:n-word-bytes))))) (sb-sys:sap-ref-word from i))))
(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)))))
(declaim (inline read-ascii-string-optimized)) (declaim (inline read-ascii-string-optimized))
(defun read-ascii-string-optimized (length string stream) (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