File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 144144
145145(defun restore-bignum (storage)
146146 (declare (optimize (speed 3 ) (safety 1 )))
147- (let ((count (restore-tagged-fixnum storage)))
147+ (let* ((count (restore-tagged-fixnum storage))
148+ (num-words (abs count )))
148149 (declare (type fixnum count ))
149- (ensure-enough-data storage (the fixnum (* 4 (abs count ))))
150- (* (if (< count 0 ) -1 1 )
151- (bits->num
152- (loop repeat (the fixnum (abs count ))
153- collect (restore-ub32 storage))))))
150+ (unless (<= num-words (ash most-positive-fixnum -2 ))
151+ (unexpected-data " number of words in bignum" num-words))
152+ (check-if-too-much-data (read-storage-max-to-read storage)
153+ (truly-the fixnum (* 4 num-words)))
154+ (let ((sum 0 ))
155+ (loop
156+ repeat num-words
157+ for pos from 0 by 32
158+ do
159+ (ensure-enough-data storage 4 )
160+ (incf sum (* (restore-ub32 storage) (expt 2 pos))))
161+ (* (if (< count 0 ) -1 1 ) sum))))
154162
155163(defun store-bignum (bignum storage)
156164 (when storage
You can’t perform that action at this time.
0 commit comments