Skip to content

Commit

Permalink
Remove class cache, it's not used anywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
stassats committed Dec 27, 2011
1 parent 4181e6c commit ace1e4b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 52 deletions.
7 changes: 1 addition & 6 deletions disk.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@
(finalize-inheritance class))
(+ 1 ;; type
(object-size (class-name class))
1 ;; class-id
+sequence-length+ ;; list length
(reduce #'+ (slots-to-store class)
:key (lambda (x)
Expand All @@ -360,7 +359,6 @@
(defmethod write-object ((class storable-class) stream)
(write-n-bytes #.(type-code 'storable-class) 1 stream)
(write-object (class-name class) stream)
(write-n-bytes (class-id class) 1 stream)
(unless (class-finalized-p class)
(finalize-inheritance class))
(let ((slots (slots-to-store class)))
Expand All @@ -370,12 +368,9 @@
stream))))

(defreader storable-class (stream)
(let ((class (find-class (read-next-object stream)))
(id (read-n-bytes 1 stream)))
(cache-class class id)
(let ((class (find-class (read-next-object stream))))
(unless (class-finalized-p class)
(finalize-inheritance class))
(pushnew class (storage-data (class-storage class)))
(setf (objects-of-class class) nil)
(let* ((length (read-n-bytes +sequence-length+ stream))
(vector (make-array length)))
Expand Down
2 changes: 1 addition & 1 deletion io-generic.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(declaim (inline read-n-signed-bytes))
(defun read-n-signed-bytes (n stream)
(let ((byte (read-n-bytes n stream)))
(logior byte (- (logand byte (ash 1 (1- (* n 8))))))))
(logior byte (- (mask-field (byte 1 (1- (* n 8))) byte)))))

(declaim (inline read-2-bytes read-3-bytes read-4-bytes))
(defun read-2-bytes (stream)
Expand Down
30 changes: 1 addition & 29 deletions mop.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

(in-package #:storage)

(declaim (inline indexes))

(defclass storage ()
((data :initform nil
:accessor storage-data)
Expand All @@ -27,8 +25,6 @@
:accessor class-relations)
(initforms :initform nil
:accessor class-initforms)
(class-id :initform 0
:accessor class-id)
(objects :initform nil
:accessor objects-of-class)
(storage :initform nil
Expand Down Expand Up @@ -56,29 +52,6 @@

;;;

(defvar *class-cache* #())

(defun grow-cache ()
(let* ((next-position (length *class-cache*))
(new-cache (make-array (+ next-position 20) :initial-element nil)))
(replace new-cache *class-cache*)
(setf *class-cache* new-cache)
next-position))

(defun assign-id-to-class (class)
(loop for i from 0
for cached-class across *class-cache*
unless cached-class
return (cache-class-with-id class i)
when (eq cached-class class)
return (setf (class-id class) i)
finally (cache-class-with-id class (grow-cache)))
t)

(defun cache-class-with-id (class id)
(setf (class-id class) id)
(setf (aref *class-cache* id) class))

(defmethod validate-superclass
((class standard-class)
(superclass storable-class))
Expand Down Expand Up @@ -192,8 +165,7 @@

(defmethod initialize-instance :after ((class storable-class) &key)
(when (class-storage class)
(pushnew class (storage-data (class-storage class)) :test #'eq))
(assign-id-to-class class))
(pushnew class (storage-data (class-storage class)) :test #'eq)))

;;;

Expand Down
16 changes: 0 additions & 16 deletions storage.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@

(defvar *storage* nil)

(defvar *read-class-cache* #())
(declaim (simple-vector *read-class-cache*))

(defun grow-read-cache (id)
(let ((new-cache (make-array (+ id 10) :initial-element nil)))
(replace new-cache *read-class-cache*)
(setf *read-class-cache* new-cache)))

(defun cache-class (class id)
(unless (array-in-bounds-p *read-class-cache* id)
(grow-read-cache id))
(setf (aref *read-class-cache* id) class))

(defun find-class-by-id (id)
(aref *read-class-cache* id))

(defun objects-of-type (type)
(objects-of-class (find-class type)))

Expand Down

0 comments on commit ace1e4b

Please sign in to comment.