|
From: | Stefan Monnier |
Subject: | Re: master daea9b3 1/2: Read mailcaps again only when necessary |
Date: | Mon, 01 Nov 2021 12:56:37 -0400 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> +(defun file-has-changed-p (file) > + "Return non-nil if FILE has changed. > +The modification time of FILE is compared to the modification > +time of FILE during a previous invocation of `file-has-changed-p'. > +Therefore the first invocation of `file-has-changed-p' always > +returns non-nil." > + (let* ((attr (file-attributes file 'integer)) > + (mtime (file-attribute-modification-time attr)) > + (saved-mtime (gethash (intern file) > + file-has-changed-p--hash-table))) > + (when (not (equal mtime saved-mtime)) > + (puthash (intern file) mtime file-has-changed-p--hash-table)))) This API doesn't seem safe. If two packages read&parse the same file and both rely on this function to decide when to reparse, the second package can get a nil value (because the first has caused the mtime to be reset in the hash table) even though the file has changed since it last parsed it. So I think the function needs a second argument which represents the "since when". It could be the hash-table. Side question: why use `intern`? Why not just pass `:test #'equal` to the `make-hash-table`? Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |