Skip to content

Commit

Permalink
perf: Don't do unneeded calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed May 30, 2024
1 parent 4b293a7 commit 7a7b671
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ calculate to the right side."
;; This is smart since we add up the string size before the calculation!
(setq str-len (+ str-len opposing-str-len))
;; Start the calculation!
(let* ((column-start (sideline--window-hscroll))
(win-width (sideline--window-width))
(pos-end (max (sideline--line-width) column-start)))
(when-let* ((win-width (sideline--render-data :win-width))
((<= str-len win-width))
(column-start (sideline--render-data :hscroll))
(pos-end (max (sideline--line-width) column-start)))
(cond
((> str-len win-width) nil)
(on-left
(let ((pos-first (save-excursion (back-to-indentation) (current-column))))
(cond ((<= str-len (- pos-first column-start))
Expand Down Expand Up @@ -559,7 +559,7 @@ FACE, NAME, ON-LEFT, and ORDER for details."
(len-title (sideline--str-len title))
(data (sideline--find-line len-title on-left order))
(pos-start (nth 0 data)) (pos-end (nth 1 data)) (occ-pt (nth 2 data))
(offset (- 0 (sideline--window-hscroll)))
(offset (- 0 (sideline--render-data :hscroll)))
(str (concat
(unless on-left
(propertize " "
Expand Down Expand Up @@ -663,7 +663,9 @@ If argument ON-LEFT is non-nil, it will align to the left instead of right."
(unless (funcall sideline-inhibit-display-function)
(setq sideline--render-data
`( :eol ,(sideline--window-end)
:bol ,(window-start)))
:bol ,(window-start)
:hscroll ,(sideline--window-hscroll)
:win-width ,(sideline--window-width)))
(run-hooks 'sideline-pre-render-hook)
(sideline--render-backends sideline-backends-left t)
(sideline--render-backends sideline-backends-right nil)
Expand Down

0 comments on commit 7a7b671

Please sign in to comment.