Use buffer-chars-modified-tick instead of buffer-modified-tick

This commit is contained in:
Ihor Radchenko 2021-03-29 08:54:50 +08:00 committed by Adam Porter
parent 6e7371ce61
commit 675d333b91

View file

@ -481,7 +481,7 @@ NARROW corresponds to the `org-ql-select' argument NARROW."
(if-let* ((buffer-cache (gethash (current-buffer) org-ql-cache)) (if-let* ((buffer-cache (gethash (current-buffer) org-ql-cache))
(query-cache (cadr buffer-cache)) (query-cache (cadr buffer-cache))
(modified-tick (car buffer-cache)) (modified-tick (car buffer-cache))
(buffer-unmodified-p (eq (buffer-modified-tick) modified-tick)) (buffer-unmodified-p (eq (buffer-chars-modified-tick) modified-tick))
(cached-result (gethash query-cache-key query-cache))) (cached-result (gethash query-cache-key query-cache)))
(pcase cached-result (pcase cached-result
('org-ql-nil nil) ('org-ql-nil nil)
@ -490,7 +490,7 @@ NARROW corresponds to the `org-ql-select' argument NARROW."
(cond ((or (not query-cache) (cond ((or (not query-cache)
(not buffer-unmodified-p)) (not buffer-unmodified-p))
(puthash (current-buffer) (puthash (current-buffer)
(list (buffer-modified-tick) (list (buffer-chars-modified-tick)
(let ((table (make-hash-table :test 'org-ql-hash-test))) (let ((table (make-hash-table :test 'org-ql-hash-test)))
(puthash query-cache-key (or new-result 'org-ql-nil) table) (puthash query-cache-key (or new-result 'org-ql-nil) table)
table)) table))
@ -545,7 +545,7 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
(if-let* ((buffer-cache (gethash (current-buffer) org-ql-tags-cache)) (if-let* ((buffer-cache (gethash (current-buffer) org-ql-tags-cache))
(modified-tick (car buffer-cache)) (modified-tick (car buffer-cache))
(tags-cache (cdr buffer-cache)) (tags-cache (cdr buffer-cache))
(buffer-unmodified-p (eq (buffer-modified-tick) modified-tick)) (buffer-unmodified-p (eq (buffer-chars-modified-tick) modified-tick))
(cached-result (gethash position tags-cache))) (cached-result (gethash position tags-cache)))
;; Found in cache: return them. ;; Found in cache: return them.
;; FIXME: Isn't `cached-result' a list of (INHERITED . LOCAL)? It ;; FIXME: Isn't `cached-result' a list of (INHERITED . LOCAL)? It
@ -586,12 +586,12 @@ Returns cons (INHERITED-TAGS . LOCAL-TAGS)."
(setf buffer-cache (gethash (current-buffer) org-ql-tags-cache) (setf buffer-cache (gethash (current-buffer) org-ql-tags-cache)
modified-tick (car buffer-cache) modified-tick (car buffer-cache)
tags-cache (cdr buffer-cache) tags-cache (cdr buffer-cache)
buffer-unmodified-p (eq (buffer-modified-tick) modified-tick)) buffer-unmodified-p (eq (buffer-chars-modified-tick) modified-tick))
(unless (and buffer-cache buffer-unmodified-p) (unless (and buffer-cache buffer-unmodified-p)
;; Buffer-local tags cache empty or invalid: make new one. ;; Buffer-local tags cache empty or invalid: make new one.
(setf tags-cache (make-hash-table)) (setf tags-cache (make-hash-table))
(puthash (current-buffer) (puthash (current-buffer)
(cons (buffer-modified-tick) tags-cache) (cons (buffer-chars-modified-tick) tags-cache)
org-ql-tags-cache)) org-ql-tags-cache))
(puthash position all-tags tags-cache)))) (puthash position all-tags tags-cache))))
@ -622,7 +622,7 @@ Values compared with `equal'."
(pcase (if-let* ((buffer-cache (gethash (current-buffer) org-ql-node-value-cache)) (pcase (if-let* ((buffer-cache (gethash (current-buffer) org-ql-node-value-cache))
(modified-tick (car buffer-cache)) (modified-tick (car buffer-cache))
(position-cache (cdr buffer-cache)) (position-cache (cdr buffer-cache))
(buffer-unmodified-p (eq (buffer-modified-tick) modified-tick)) (buffer-unmodified-p (eq (buffer-chars-modified-tick) modified-tick))
(value-cache (gethash position position-cache)) (value-cache (gethash position position-cache))
(cached-value (alist-get fn value-cache nil nil #'equal))) (cached-value (alist-get fn value-cache nil nil #'equal)))
;; Found in cache: return it. ;; Found in cache: return it.
@ -637,13 +637,13 @@ Values compared with `equal'."
position-cache (cdr buffer-cache) position-cache (cdr buffer-cache)
value-cache (when position-cache value-cache (when position-cache
(gethash position position-cache)) (gethash position position-cache))
buffer-unmodified-p (eq (buffer-modified-tick) modified-tick)) buffer-unmodified-p (eq (buffer-chars-modified-tick) modified-tick))
(unless (and buffer-cache buffer-unmodified-p) (unless (and buffer-cache buffer-unmodified-p)
;; Buffer-local node cache empty or invalid: make new one. ;; Buffer-local node cache empty or invalid: make new one.
(setf position-cache (make-hash-table) (setf position-cache (make-hash-table)
value-cache (gethash position position-cache)) value-cache (gethash position position-cache))
(puthash (current-buffer) (puthash (current-buffer)
(cons (buffer-modified-tick) position-cache) (cons (buffer-chars-modified-tick) position-cache)
org-ql-node-value-cache)) org-ql-node-value-cache))
(setf (alist-get fn value-cache nil nil #'equal) new-value) (setf (alist-get fn value-cache nil nil #'equal) new-value)
(puthash position value-cache position-cache) (puthash position value-cache position-cache)