org-latex-preview: Reduce overhead in SVG editing

* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor):
By setting the coding system and avoiding triggering any file
handlers (such as the `image-file-handler'), memory usage is nearly
halved, reducing GC pressure.
This commit is contained in:
TEC 2023-01-03 16:46:35 +08:00
parent 9884886692
commit 7a4925cac6
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 8 additions and 1 deletions

View File

@ -1189,7 +1189,14 @@ EXTENDED-INFO, and displayed in the buffer."
The foreground color is guessed to be the first specified <g>
fill color, which appears to be a reliable heuristic from a few
tests with the output of dvisvgm."
(let ((write-region-inhibit-fsync t))
(let ((write-region-inhibit-fsync t)
;; dvisvgm produces UTF-8 encoded files, so we might as well
;; avoid calling `find-auto-coding'.
(coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8)
;; Prevent any file handlers (specifically
;; `image-file-handler') from being called.
(file-name-handler-alist nil))
(with-temp-buffer
(insert-file-contents (plist-get svg-fragment :path))
(goto-char (point-min))