Skip to content

Commit

Permalink
feat: improve breakpoint refresh efficiency by targeting only buffers… (
Browse files Browse the repository at this point in the history
#754)

* feat: improve breakpoint refresh efficiency by targeting only buffers with at least one breakpoint

* fix: use ht-keys instead of custom key extractor function (review !754)

---------

Co-authored-by: Samuele Favazza <[email protected]>
  • Loading branch information
sfavazza and sfavazza-duagon authored Sep 18, 2023
1 parent 096070a commit a31f249
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dap-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,14 @@ will be reversed."
"Get all file backed buffers."
(-filter 'buffer-file-name (buffer-list)))

(defun dap--buffers-w-breakpoints ()
"Get only the buffers featuring at least one breakpoint"
;; get the list from the keys of the breakpoint hash-table
(ht-keys (dap--get-breakpoints)))

(defun dap--refresh-breakpoints ()
"Refresh breakpoints for DEBUG-SESSION."
(--each (dap--buffer-list)
(--each (dap--buffers-w-breakpoints)
(when (buffer-live-p it)
(with-current-buffer it
(dap--set-breakpoints-in-file
Expand Down Expand Up @@ -1567,10 +1572,10 @@ When ALL? is non-nil select from threads in all debug sessions."

(when new-session
(let ((breakpoints (dap--get-breakpoints)))
(--each (dap--buffer-list) (with-current-buffer it
(->> breakpoints
(gethash buffer-file-name)
(dap--set-breakpoints-in-file buffer-file-name))))))
(--each (dap--buffers-w-breakpoints) (with-current-buffer it
(->> breakpoints
(gethash buffer-file-name)
(dap--set-breakpoints-in-file buffer-file-name))))))

(run-hook-with-args 'dap-session-changed-hook lsp--cur-workspace)

Expand Down

0 comments on commit a31f249

Please sign in to comment.