Skip to content

Commit

Permalink
Change order of top-level forms in cache.lisp
Browse files Browse the repository at this point in the history
  • Loading branch information
scymtym committed Jul 27, 2024
1 parent 3473c87 commit fe61a7c
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions code/cache.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@
(length prefix) (list prefix)
(length suffix) (list suffix))))

(defun gap-start (cache)
(let ((prefix (prefix cache)))
(if (null prefix)
0
(1+ (end-line (first prefix))))))

(defun gap-end (cache)
(let ((suffix (suffix cache)))
(1- (if (null suffix)
(line-count cache)
(start-line (first suffix))))))

(defun total-width (cache)
(let ((prefix-width (prefix-width cache))
(suffix-width (suffix-width cache)))
(max (if (null prefix-width) 0 (first prefix-width))
(max-line-length cache (gap-start cache) (gap-end cache))
(if (null suffix-width) 0 (first suffix-width)))))

;;; Given a cache and an interval of lines, return the maxium length
;;; of any lines in the interval.
(defun max-line-length (cache first-line-number last-line-number)
Expand Down Expand Up @@ -170,25 +189,6 @@
(:method ((cache cache))
(push-to-suffix cache (pop-from-prefix cache))))

(defun gap-start (cache)
(let ((prefix (prefix cache)))
(if (null prefix)
0
(1+ (end-line (first prefix))))))

(defun gap-end (cache)
(let ((suffix (suffix cache)))
(1- (if (null suffix)
(line-count cache)
(start-line (first suffix))))))

(defun total-width (cache)
(let ((prefix-width (prefix-width cache))
(suffix-width (suffix-width cache)))
(max (if (null prefix-width) 0 (first prefix-width))
(max-line-length cache (gap-start cache) (gap-end cache))
(if (null suffix-width) 0 (first suffix-width)))))

(defun pop-from-worklist (cache)
(pop (worklist cache)))

Expand Down

0 comments on commit fe61a7c

Please sign in to comment.