1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-23 18:47:57 +00:00

Make string-pixel-width slightly speedier

* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up
string-pixel-width in the zero-length string case.
This commit is contained in:
Lars Ingebrigtsen 2022-02-19 14:20:30 +01:00
parent 14562b45bd
commit babfb064c4

View File

@ -444,9 +444,11 @@ is inserted before adjusting the number of empty lines."
;;;###autoload
(defun string-pixel-width (string)
"Return the width of STRING in pixels."
(with-temp-buffer
(insert string)
(car (buffer-text-pixel-size nil nil t))))
(if (zerop (length string))
0
(with-temp-buffer
(insert string)
(car (buffer-text-pixel-size nil nil t)))))
;;;###autoload
(defun string-glyph-split (string)