X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fdebug-var-io.lisp;h=94a59cec7eac82caffacaa157fb34a26383ce32f;hb=a3d4610158f227d53cb5eac287dd2661e975fc70;hp=2d489d24e8dff81f6f7678044169c794e59730ab;hpb=74b85683465d011de59b1ca9486f55d594fb43d6;p=sbcl.git diff --git a/src/code/debug-var-io.lisp b/src/code/debug-var-io.lisp index 2d489d2..94a59ce 100644 --- a/src/code/debug-var-io.lisp +++ b/src/code/debug-var-io.lisp @@ -21,28 +21,29 @@ ;;; Given a byte vector VEC and an index variable INDEX, read a ;;; variable length integer and advance index. -;;; -;;; FIXME: This is called O(20) times. It should be reimplemented -;;; with much of its logic in a single service function which can -;;; be called by the macro expansion: -;;; `(SETF ,INDEX (%READ-VAR-INTEGER ,VEC ,INDEX)). +(defun %read-var-integer (vec index) + (let ((val (aref vec index))) + (cond ((<= val 253) + (values val (1+ index))) + ((= val 254) + (values + (logior (aref vec (+ index 1)) + (ash (aref vec (+ index 2)) 8)) + (+ index 3))) + (t + (values + (logior (aref vec (+ index 1)) + (ash (aref vec (+ index 2)) 8) + (ash (aref vec (+ index 3)) 16) + (ash (aref vec (+ index 4)) 24)) + (+ index 5)))))) + (defmacro read-var-integer (vec index) - (once-only ((val `(aref ,vec ,index))) - `(cond ((<= ,val 253) - (incf ,index) - ,val) - ((= ,val 254) - (prog1 - (logior (aref ,vec (+ ,index 1)) - (ash (aref ,vec (+ ,index 2)) 8)) - (incf ,index 3))) - (t - (prog1 - (logior (aref ,vec (+ ,index 1)) - (ash (aref ,vec (+ ,index 2)) 8) - (ash (aref ,vec (+ ,index 3)) 16) - (ash (aref ,vec (+ ,index 4)) 24)) - (incf ,index 5)))))) + (once-only ((vec vec)) + `(multiple-value-bind (vector new-index) + (%read-var-integer ,vec ,index) + (setf ,index new-index) + vector))) ;;; Take an adjustable vector VEC with a fill pointer and push the ;;; variable length representation of INT on the end.