mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-18 07:13:04 +00:00
Make less garbage in overlay heavy buffers
* yasnippet.el (yas-active-snippets): Use dolist+when-push instead of mapcar+delq.
This commit is contained in:
parent
4f78d03f85
commit
4af33546d8
19
yasnippet.el
19
yasnippet.el
@ -3273,12 +3273,19 @@ equivalent to a range covering the whole buffer."
|
|||||||
(setq beg (point-min) end (point-max)))
|
(setq beg (point-min) end (point-max)))
|
||||||
((not end)
|
((not end)
|
||||||
(setq end (1+ beg))))
|
(setq end (1+ beg))))
|
||||||
(cl-sort
|
|
||||||
(delete-dups ;; Snippets have multiple overlays.
|
;; Note: don't use `mapcar' here, since it would allocate in
|
||||||
(delq nil
|
;; proportion to the amount of overlays, even though the list of
|
||||||
(mapcar (lambda (ov) (overlay-get ov 'yas--snippet))
|
;; active snippets should be very small. That is important because
|
||||||
(overlays-in beg end))))
|
;; this function is called in the post-command hook (via
|
||||||
#'>= :key #'yas--snippet-id))
|
;; `yas--check-commit-snippet').
|
||||||
|
(let ((snippets nil))
|
||||||
|
(dolist (ov (overlays-in beg end))
|
||||||
|
(let ((snippet (overlay-get ov 'yas--snippet)))
|
||||||
|
;; Snippets have multiple overlays, so check for dups.
|
||||||
|
(when (and snippet (not (memq snippet snippets)))
|
||||||
|
(push snippet snippets))))
|
||||||
|
(cl-sort snippets #'>= :key #'yas--snippet-id)))
|
||||||
|
|
||||||
(define-obsolete-function-alias 'yas--snippets-at-point
|
(define-obsolete-function-alias 'yas--snippets-at-point
|
||||||
'yas-active-snippets "0.12")
|
'yas-active-snippets "0.12")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user