Make with-buffer-unmodified-if-unchanged more efficient

* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Make more efficient.
This commit is contained in:
Lars Ingebrigtsen 2022-05-03 22:06:31 +02:00
parent b7ddd0f2fd
commit 0a2f0e7f8c

View file

@ -439,9 +439,9 @@ modification status:
;; If we didn't change anything in the buffer (and the buffer
;; was previously unmodified), then flip the modification status
;; back to "unchanged".
(when (buffer-live-p ,buffer)
(when (and ,hash (buffer-live-p ,buffer))
(with-current-buffer ,buffer
(when (and ,hash (buffer-modified-p)
(when (and (buffer-modified-p)
(equal ,hash (buffer-hash)))
(restore-buffer-modified-p nil))))))))