From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Gregory Heytings <gregory@heytings.org>
Subject: Re: master daea9b3 1/2: Read mailcaps again only when necessary
Date: Mon, 01 Nov 2021 12:56:37 -0400 [thread overview]
Message-ID: <jwvfssfu8by.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20211101135346.2EBEB20B72@vcs0.savannah.gnu.org> (Lars Ingebrigtsen's message of "Mon, 1 Nov 2021 09:53:46 -0400 (EDT)")
> +(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
next parent reply other threads:[~2021-11-01 16:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211101135344.25800.81476@vcs0.savannah.gnu.org>
[not found] ` <20211101135346.2EBEB20B72@vcs0.savannah.gnu.org>
2021-11-01 16:56 ` Stefan Monnier [this message]
2021-11-01 17:01 ` master daea9b3 1/2: Read mailcaps again only when necessary Lars Ingebrigtsen
2021-11-01 17:19 ` Eli Zaretskii
2021-11-01 17:21 ` Lars Ingebrigtsen
2021-11-01 17:24 ` Eli Zaretskii
2021-11-01 17:29 ` Lars Ingebrigtsen
2021-11-01 18:13 ` Eli Zaretskii
2021-11-01 18:35 ` Stefan Monnier
2021-11-01 18:56 ` Eli Zaretskii
2021-11-01 21:07 ` Stefan Monnier
2021-11-02 12:54 ` Eli Zaretskii
2021-11-02 13:51 ` Stefan Monnier
2021-11-01 18:20 ` Stefan Monnier
2021-11-01 18:31 ` Eli Zaretskii
2021-11-01 18:06 ` Stefan Monnier
2021-11-01 18:48 ` Lars Ingebrigtsen
2021-11-01 18:50 ` Stefan Monnier
2021-11-01 19:04 ` Lars Ingebrigtsen
2021-11-01 21:31 ` Stefan Monnier
2021-11-02 14:54 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvfssfu8by.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=gregory@heytings.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).