projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
14562b4
)
Make string-pixel-width slightly speedier
author
Lars Ingebrigtsen
<larsi@gnus.org>
Sat, 19 Feb 2022 13:20:30 +0000
(14:20 +0100)
committer
Lars Ingebrigtsen
<larsi@gnus.org>
Sat, 19 Feb 2022 13:21:19 +0000
(14:21 +0100)
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Speed up
string-pixel-width in the zero-length string case.
lisp/emacs-lisp/subr-x.el
patch
|
blob
|
history
diff --git
a/lisp/emacs-lisp/subr-x.el
b/lisp/emacs-lisp/subr-x.el
index 1f69850958c6dc4aaa40533f6a9cc8306786bde2..647397e7f7b37b32dec97b5a9ee8d041cb038d3a 100644
(file)
--- a/
lisp/emacs-lisp/subr-x.el
+++ b/
lisp/emacs-lisp/subr-x.el
@@
-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)