git-svn-id: http://svn.internal.itasoftware.com/svn/ita/trunk/qres/lisp/quux/protobufs@547034
f8382938-511b-0410-9cdd-
bb47b084005c
(declaim (inline proto-whitespace-char-p))
(defun proto-whitespace-char-p (ch)
(declaim (inline proto-whitespace-char-p))
(defun proto-whitespace-char-p (ch)
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
- (and ch (member ch '(#\space #\tab #\return #\newline)))))
+ (declare #.$optimize-fast-unsafe)
+ (and ch (member ch '(#\space #\tab #\return #\newline))))
(declaim (inline proto-eol-char-p))
(defun proto-eol-char-p (ch)
(declaim (inline proto-eol-char-p))
(defun proto-eol-char-p (ch)
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
- (and ch (member ch '(#\return #\newline)))))
+ (declare #.$optimize-fast-unsafe)
+ (and ch (member ch '(#\return #\newline))))
(declaim (inline proto-token-char-p))
(defun proto-token-char-p (ch)
(declaim (inline proto-token-char-p))
(defun proto-token-char-p (ch)
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
- (and ch (or (alpha-char-p ch)
- (digit-char-p ch)
- (member ch '(#\_ #\.))))))
+ (declare #.$optimize-fast-unsafe)
+ (and ch (or (alpha-char-p ch)
+ (digit-char-p ch)
+ (member ch '(#\_ #\.)))))
(defun skip-whitespace (stream)
(defun skip-whitespace (stream)
(return-from generate-serializer
`(defmethod serialize-object
(,vobj (,vclass (eql ,message)) ,vbuf &optional (,vidx 0) visited)
(return-from generate-serializer
`(defmethod serialize-object
(,vobj (,vclass (eql ,message)) ,vbuf &optional (,vidx 0) visited)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (ignorable ,vobj ,vclass visited)
(type (simple-array (unsigned-byte 8)) ,vbuf)
(type fixnum ,vidx))
(declare (ignorable ,vobj ,vclass visited)
(type (simple-array (unsigned-byte 8)) ,vbuf)
(type fixnum ,vidx))
(setq ,vidx (serialize-enum ,vval '(,@(proto-values msg)) ,tag ,vbuf ,vidx)))))))))))))
`(defmethod serialize-object
(,vobj (,vclass (eql ,message)) ,vbuf &optional (,vidx 0) visited)
(setq ,vidx (serialize-enum ,vval '(,@(proto-values msg)) ,tag ,vbuf ,vidx)))))))))))))
`(defmethod serialize-object
(,vobj (,vclass (eql ,message)) ,vbuf &optional (,vidx 0) visited)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (ignorable visited)
(type (simple-array (unsigned-byte 8)) ,vbuf)
(type fixnum ,vidx))
(declare (ignorable visited)
(type (simple-array (unsigned-byte 8)) ,vbuf)
(type fixnum ,vidx))
(return-from generate-deserializer
`(defmethod deserialize-object
((,vclass (eql ,message)) ,vbuf &optional ,vidx ,vlen (,vendtag 0))
(return-from generate-deserializer
`(defmethod deserialize-object
((,vclass (eql ,message)) ,vbuf &optional ,vidx ,vlen (,vendtag 0))
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (ignorable ,vclass ,vbuf ,vlen ,vendtag)
(type (simple-array (unsigned-byte 8)) ,vbuf))
(let ((,vidx (or ,vidx 0)))
(declare (ignorable ,vclass ,vbuf ,vlen ,vendtag)
(type (simple-array (unsigned-byte 8)) ,vbuf))
(let ((,vidx (or ,vidx 0)))
(rtemps (mapcar #'second rslots)))
`(defmethod deserialize-object
((,vclass (eql ,message)) ,vbuf &optional ,vidx ,vlen (,vendtag 0))
(rtemps (mapcar #'second rslots)))
`(defmethod deserialize-object
((,vclass (eql ,message)) ,vbuf &optional ,vidx ,vlen (,vendtag 0))
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) ,vbuf))
(let ((,vidx (or ,vidx 0))
(,vlen (or ,vlen (length ,vbuf))))
(declare (type (simple-array (unsigned-byte 8)) ,vbuf))
(let ((,vidx (or ,vidx 0))
(,vlen (or ,vlen (length ,vbuf))))
(return-from generate-object-size
`(defmethod object-size
(,vobj (,vclass (eql ,message)) &optional visited)
(return-from generate-object-size
`(defmethod object-size
(,vobj (,vclass (eql ,message)) &optional visited)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (ignorable ,vobj visited))
0)))
(with-collectors ((sizers collect-sizer))
(declare (ignorable ,vobj visited))
0)))
(with-collectors ((sizers collect-sizer))
(iincf ,vsize (enum-size ,vval '(,@(proto-values msg)) ,tag)))))))))))))
`(defmethod object-size
(,vobj (,vclass (eql ,message)) &optional visited)
(iincf ,vsize (enum-size ,vval '(,@(proto-values msg)) ,tag)))))))))))))
`(defmethod object-size
(,vobj (,vclass (eql ,message)) &optional visited)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (ignorable visited))
(let ((,vsize (and visited (gethash ,vobj visited))))
(when ,vsize
(declare (ignorable visited))
(let ((,vsize (and visited (gethash ,vobj visited))))
(when ,vsize
;;; Optimized fixnum arithmetic
;;; Optimized fixnum arithmetic
+(defconstant $optimize-default '(optimize (speed 1) (safety 3) (debug 3))
+ "Compiler optimization settings for safe, debuggable code.")
+
+(defconstant $optimize-fast-unsafe '(optimize (speed 3) (safety 0) (debug 0))
+ "Compiler optimization settings for fast, unsafe, hard-to-debug code.")
+
+
(defmacro i+ (&rest fixnums)
`(the fixnum (+ ,@(loop for n in fixnums collect `(the fixnum ,n)))))
(defmacro i+ (&rest fixnums)
`(the fixnum (+ ,@(loop for n in fixnums collect `(the fixnum ,n)))))
(define-modify-macro idecf (&optional (delta 1)) i-)
(defmacro ildb (bytespec value)
(define-modify-macro idecf (&optional (delta 1)) i-)
(defmacro ildb (bytespec value)
- `(ldb ,bytespec (the fixnum ,value)))
+ `(the fixnum (ldb ,bytespec (the fixnum ,value))))
(eval-when (:compile-toplevel :load-toplevel :execute)
(eval-when (:compile-toplevel :load-toplevel :execute)
+;; If you need to debug the (de)serializer, (pushnew :debug-serialization *features*)
+;; Otherwise, we try to make (de)serialization as fast as possible,
+;; risking life and limb to do so
+(defconstant $optimize-serialization
+ #+debug-serialization $optimize-default
+ #-debug-serialization $optimize-fast-unsafe)
+
(defconstant $wire-type-varint 0)
(defconstant $wire-type-64bit 1)
(defconstant $wire-type-string 2)
(defconstant $wire-type-varint 0)
(defconstant $wire-type-64bit 1)
(defconstant $wire-type-string 2)
-(defconstant $wire-type-start-group 3) ;supposedly obsolete
-(defconstant $wire-type-end-group 4) ;supposedly obsolete
+(defconstant $wire-type-start-group 3) ;supposedly deprecated, but no such luck
+(defconstant $wire-type-end-group 4) ;supposedly deprecated
(defconstant $wire-type-32bit 5)
) ;eval-when
(defconstant $wire-type-32bit 5)
) ;eval-when
(defun make-tag (type index)
"Given a wire type or the name of a Protobufs type and a field index,
return the tag that encodes both of them."
(defun make-tag (type index)
"Given a wire type or the name of a Protobufs type and a field index,
return the tag that encodes both of them."
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(if (typep type 'fixnum)
(ilogior type (iash index 3))
(let ((type (ecase type
(if (typep type 'fixnum)
(ilogior type (iash index 3))
(let ((type (ecase type
(defun zig-zag-encode32 (val)
(defun zig-zag-encode32 (val)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (signed-byte 32) val))
(logxor (ash val 1) (ash val -31)))
(defun zig-zag-encode64 (val)
(declare (type (signed-byte 32) val))
(logxor (ash val 1) (ash val -31)))
(defun zig-zag-encode64 (val)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (signed-byte 64) val))
(logxor (ash val 1) (ash val -63)))
(define-compiler-macro zig-zag-encode32 (&whole form val)
(if (atom val)
(declare (type (signed-byte 64) val))
(logxor (ash val 1) (ash val -63)))
(define-compiler-macro zig-zag-encode32 (&whole form val)
(if (atom val)
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (signed-byte 32) ,val))
(logxor (ash ,val 1) (ash ,val -31)))
form))
(define-compiler-macro zig-zag-encode64 (&whole form val)
(if (atom val)
(type (signed-byte 32) ,val))
(logxor (ash ,val 1) (ash ,val -31)))
form))
(define-compiler-macro zig-zag-encode64 (&whole form val)
(if (atom val)
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (signed-byte 64) ,val))
(logxor (ash ,val 1) (ash ,val -63)))
form))
(defun zig-zag-decode32 (val)
(type (signed-byte 64) ,val))
(logxor (ash ,val 1) (ash ,val -63)))
form))
(defun zig-zag-decode32 (val)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(logxor (ash val -1) (- (logand val 1))))
(defun zig-zag-decode64 (val)
(logxor (ash val -1) (- (logand val 1))))
(defun zig-zag-decode64 (val)
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(logxor (ash val -1) (- (logand val 1))))
(define-compiler-macro zig-zag-decode32 (&whole form val)
(if (atom val)
(logxor (ash val -1) (- (logand val 1))))
(define-compiler-macro zig-zag-decode32 (&whole form val)
(if (atom val)
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ `(locally (declare #.$optimize-serialization)
(logxor (ash ,val -1) (- (logand ,val 1))))
form))
(define-compiler-macro zig-zag-decode64 (&whole form val)
(if (atom val)
(logxor (ash ,val -1) (- (logand ,val 1))))
form))
(define-compiler-macro zig-zag-decode64 (&whole form val)
(if (atom val)
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ `(locally (declare #.$optimize-serialization)
(logxor (ash ,val -1) (- (logand ,val 1))))
form))
(logxor (ash ,val -1) (- (logand ,val 1))))
form))
(declare
(type (unsigned-byte 32) tag)
(type fixnum index))
(declare
(type (unsigned-byte 32) tag)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(ecase type
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(ecase type
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (simple-array (unsigned-byte 8)) ,buffer)
;; 'tag' is a constant, no need to declare its type
(type fixnum ,index))
(type (simple-array (unsigned-byte 8)) ,buffer)
;; 'tag' is a constant, no need to declare its type
(type fixnum ,index))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(multiple-value-bind (full-len len)
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(multiple-value-bind (full-len len)
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (simple-array (unsigned-byte 8)) ,buffer)
;; 'tag' is a constant, no need to declare its type
(type fixnum ,index))
(type (simple-array (unsigned-byte 8)) ,buffer)
;; 'tag' is a constant, no need to declare its type
(type fixnum ,index))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(let* ((val (let ((e (find val enum-values :key #'proto-value)))
(and e (proto-index e))))
(idx (encode-uint32 tag buffer index)))
(let* ((val (let ((e (find val enum-values :key #'proto-value)))
(and e (proto-index e))))
(idx (encode-uint32 tag buffer index)))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type (unsigned-byte 32) tag)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(multiple-value-bind (full-len len)
(let ((idx (encode-uint32 tag buffer index)))
(declare (type fixnum idx))
(multiple-value-bind (full-len len)
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(ecase type
((:int32)
(decode-int32 buffer index))
(ecase type
((:int32)
(decode-int32 buffer index))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (simple-array (unsigned-byte 8)) ,buffer)
(type fixnum ,index))
,(ecase type
(type (simple-array (unsigned-byte 8)) ,buffer)
(type fixnum ,index))
,(ecase type
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(multiple-value-bind (len idx)
(decode-uint32 buffer index)
(declare (type (unsigned-byte 32) len)
(multiple-value-bind (len idx)
(decode-uint32 buffer index)
(declare (type (unsigned-byte 32) len)
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0))
+ `(locally (declare #.$optimize-serialization
(type (simple-array (unsigned-byte 8)) ,buffer)
(type fixnum ,index))
(block deserialize-packed
(type (simple-array (unsigned-byte 8)) ,buffer)
(type fixnum ,index))
(block deserialize-packed
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(multiple-value-bind (val idx)
(decode-int32 buffer index)
(let ((val (let ((e (find val enum-values :key #'proto-index)))
(multiple-value-bind (val idx)
(decode-int32 buffer index)
(let ((val (let ((e (find val enum-values :key #'proto-index)))
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
Watch out, this function turns off most type checking and all array bounds checking."
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(multiple-value-bind (len idx)
(decode-uint32 buffer index)
(declare (type (unsigned-byte 32) len)
(multiple-value-bind (len idx)
(decode-uint32 buffer index)
(declare (type (unsigned-byte 32) len)
"Returns the size in bytes that the primitive object will take when serialized.
Watch out, this function turns off most type checking."
(declare (type (unsigned-byte 32) tag))
"Returns the size in bytes that the primitive object will take when serialized.
Watch out, this function turns off most type checking."
(declare (type (unsigned-byte 32) tag))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(ecase type
((:int32 :uint32)
(i+ (length32 tag) (length32 (ldb (byte 32 0) val))))
(ecase type
((:int32 :uint32)
(i+ (length32 tag) (length32 (ldb (byte 32 0) val))))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:string :bytes :bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ `(locally (declare #.$optimize-serialization)
,(ecase type
((:int32)
`(i+ (length32 ,tag) (length32 (ldb (byte 32 0) ,val))))
,(ecase type
((:int32)
`(i+ (length32 ,tag) (length32 (ldb (byte 32 0) ,val))))
"Returns the size in bytes that the packed object will take when serialized.
Watch out, this function turns off most type checking."
(declare (type (unsigned-byte 32) tag))
"Returns the size in bytes that the packed object will take when serialized.
Watch out, this function turns off most type checking."
(declare (type (unsigned-byte 32) tag))
- (locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (locally (declare #.$optimize-serialization)
(let ((len (let ((len 0))
(declare (type fixnum len))
(map () #'(lambda (val)
(let ((len (let ((len 0))
(declare (type fixnum len))
(map () #'(lambda (val)
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
(if (member type '(:int32 :uint32 :int64 :uint64 :sint32 :sint64
:fixed32 :sfixed32 :fixed64 :sfixed64
:bool :float :double))
- `(locally (declare (optimize (speed 3) (safety 0) (debug 0)))
+ `(locally (declare #.$optimize-serialization)
(let ((len (let ((len 0))
(declare (type fixnum len))
(map () #'(lambda (val)
(let ((len (let ((len 0))
(declare (type fixnum len))
(map () #'(lambda (val)
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (unsigned-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (unsigned-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (unsigned-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (unsigned-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (signed-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (signed-byte 32) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (signed-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type (signed-byte 64) val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
"Encodes the single float 'val' into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Encodes the single float 'val' into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type single-float val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type single-float val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
"Encodes the double float 'val' into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Encodes the double float 'val' into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type double-float val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(declare (type double-float val)
(type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
"Encodes the octets into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Encodes the octets into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(let* ((octets (babel:string-to-octets string :encoding :utf-8))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(let* ((octets (babel:string-to-octets string :encoding :utf-8))
"Encodes the octets into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Encodes the octets into the buffer at the given index.
Modifies the buffer, and returns the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(let* ((len (length octets))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(let* ((len (length octets))
"Decodes the next 32-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 32-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Seven bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Seven bits at a time, least significant bits first
(declare (type (unsigned-byte 32) val))
(loop for places fixnum upfrom 0 by 7
for byte fixnum = (prog1 (aref buffer index) (iincf index))
(declare (type (unsigned-byte 32) val))
(loop for places fixnum upfrom 0 by 7
for byte fixnum = (prog1 (aref buffer index) (iincf index))
- do (setq val (ilogior val (iash (ildb (byte 7 0) byte) places)))
+ do (let ((bits (ildb (byte 7 0) byte)))
+ (declare (type (unsigned-byte 8) bits))
+ (setq val (ilogior val (iash bits places))))
until (i< byte 128)
finally (progn
(assert (< val #.(ash 1 32)) ()
until (i< byte 128)
finally (progn
(assert (< val #.(ash 1 32)) ()
"Decodes the next 64-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 64-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Seven bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Seven bits at a time, least significant bits first
(declare (type (unsigned-byte 64) val))
(loop for places fixnum upfrom 0 by 7
for byte fixnum = (prog1 (aref buffer index) (iincf index))
(declare (type (unsigned-byte 64) val))
(loop for places fixnum upfrom 0 by 7
for byte fixnum = (prog1 (aref buffer index) (iincf index))
- do (setq val (logior val (ash (ildb (byte 7 0) byte) places)))
+ do (let ((bits (ildb (byte 7 0) byte)))
+ (declare (type (unsigned-byte 8) bits))
+ (setq val (logior val (ash bits places))))
until (i< byte 128)
finally (return (values val index)))))
until (i< byte 128)
finally (return (values val index)))))
"Decodes the next 32-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 32-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (val index)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (val index)
"Decodes the next 64-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 64-bit varint integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (val index)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (val index)
"Decodes the next 32-bit unsigned fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 32-bit unsigned fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next unsigned 64-bit fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next unsigned 64-bit fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next 32-bit signed fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next 32-bit signed fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next signed 64-bit fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next signed 64-bit fixed integer in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next single float in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next single float in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next double float in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next double float in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
;; Eight bits at a time, least significant bits first
"Decodes the next UTF-8 encoded string in the buffer at the given index.
Returns both the decoded string and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next UTF-8 encoded string in the buffer at the given index.
Returns both the decoded string and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (len idx)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (len idx)
"Decodes the next octets in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
"Decodes the next octets in the buffer at the given index.
Returns both the decoded value and the new index into the buffer.
Watch out, this function turns off all type checking and array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (len idx)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index))
(multiple-value-bind (len idx)
(defun length32 (val)
"Returns the length that 'val' will take when encoded as a 32-bit integer."
(defun length32 (val)
"Returns the length that 'val' will take when encoded as a 32-bit integer."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 32) val))
(let ((size 0))
(declare (type fixnum size))
(declare (type (unsigned-byte 32) val))
(let ((size 0))
(declare (type fixnum size))
(defun length64 (val)
"Returns the length that 'val' will take when encoded as a 64-bit integer."
(defun length64 (val)
"Returns the length that 'val' will take when encoded as a 64-bit integer."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (unsigned-byte 64) val))
(let ((size 0))
(declare (type fixnum size))
(declare (type (unsigned-byte 64) val))
(let ((size 0))
(declare (type fixnum size))
"Skip an element in the buffer at the index of the given wire type.
Returns the new index in the buffer.
Watch out, this function turns off all type checking and all array bounds checking."
"Skip an element in the buffer at the index of the given wire type.
Returns the new index in the buffer.
Watch out, this function turns off all type checking and all array bounds checking."
- (declare (optimize (speed 3) (safety 0) (debug 0)))
+ (declare #.$optimize-serialization)
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index)
(type (unsigned-byte 32) tag))
(declare (type (simple-array (unsigned-byte 8)) buffer)
(type fixnum index)
(type (unsigned-byte 32) tag))