From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: multi-eq hash tables
Date: Tue, 03 May 2022 14:12:40 -0400 [thread overview]
Message-ID: <jwv7d72mr6f.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20220503172106.30B09C009A8@vcs2.savannah.gnu.org> (Lars Ingebrigtsen's message of "Tue, 3 May 2022 13:21:06 -0400 (EDT)")
> -(defconst tool-bar-keymap-cache (make-hash-table))
> +(defconst tool-bar-keymap-cache (make-hash-table :test #'equal))
> +
> +(defun tool-bar--cache-key ()
> + (cons (frame-terminal) (sxhash-eq tool-bar-map)))
I've seen such needs in the past.
Maybe we should introduce something like:
(define-hash-table-test shallow-equal
(lambda (x1 x2) (while (and (consp x1) (consp x2) (eql (car x1) (car x2)))
(setq x1 (cdr x1)) (setq x2 (cdr x2)))
(equal x1 x2)))
...)
and we could even improve the weakness support so that `key` used with
such a hashtable would mean that as soon as one of the values in the
key's list can be GC'd then the entry is removed.
This way we could have our hash table such that entries are flushed by
the GC when a terminal disappears or when one of the tool-bar-map
objects dies (instead of the current code which prevents us from GC'ing
the terminal objects and the old tool bar maps).
Stefan
next parent reply other threads:[~2022-05-03 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <165159846589.6567.527908635296473829@vcs2.savannah.gnu.org>
[not found] ` <20220503172106.30B09C009A8@vcs2.savannah.gnu.org>
2022-05-03 18:12 ` Stefan Monnier [this message]
2022-05-03 18:58 ` multi-eq hash tables Lars Ingebrigtsen
2022-05-03 19:30 ` [External] : " Drew Adams
2022-05-03 19:42 ` How to use markers as keys in a hash map? (was: multi-eq hash tables) Stefan Monnier
2022-05-04 15:52 ` [External] : " Drew Adams
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv7d72mr6f.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.