From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: multi-eq hash tables Date: Tue, 03 May 2022 14:12:40 -0400 Message-ID: References: <165159846589.6567.527908635296473829@vcs2.savannah.gnu.org> <20220503172106.30B09C009A8@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28403"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 03 20:14:30 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlx2c-0007C5-Gv for ged-emacs-devel@m.gmane-mx.org; Tue, 03 May 2022 20:14:30 +0200 Original-Received: from localhost ([::1]:56434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlx2a-0003ic-QG for ged-emacs-devel@m.gmane-mx.org; Tue, 03 May 2022 14:14:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlx10-0002FE-6r for emacs-devel@gnu.org; Tue, 03 May 2022 14:12:50 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlx0w-0001Pz-00 for emacs-devel@gnu.org; Tue, 03 May 2022 14:12:48 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 07570442687; Tue, 3 May 2022 14:12:43 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id ABFFB442681; Tue, 3 May 2022 14:12:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1651601561; bh=OZbtzL3j2A+p1Qp+VuCo3WQZltlzuVq3sjyAJpMpTU8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=VOK7ZTD7yXmV5txEwIps8Juk2wHaST8ZvH5ij+qAtZdjNEVDxzdYNUHRWqnRtkz5u 0QQBrfyNaJSq1XU9+74xNPVhc9Ll81nmtPfTpVCVgeN85Nw2jXNsMA+JqgkwhC8mDM 8JsiAyDbPPYd0uuJsu4U7QPEHQ8zHqUB8Y3AYCWkdIZpgPIG1nTalbQWLzVRRMtQX9 VdxGOYJEkorbG/iO9FvjKtrm58l6JSi7/zJpGhq2oy+yrIRmEOn9Bfrut5M60EDcrK +t+6P82AGOCA+d5mfsNoNwhGylHMLCBoI8RyjEV289b6pF5HM4NuvTwAkVql2ALNNY /qRdJEPYithgw== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 77610120202; Tue, 3 May 2022 14:12:41 -0400 (EDT) In-Reply-To: <20220503172106.30B09C009A8@vcs2.savannah.gnu.org> (Lars Ingebrigtsen's message of "Tue, 3 May 2022 13:21:06 -0400 (EDT)") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289119 Archived-At: > -(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