GNU bug report logs -
#78162
[PATCH] hash-table-contains-p: Avoid creating a symbol on every call
Previous Next
Reported by: Daniel Mendler <mail <at> daniel-mendler.de>
Date: Wed, 30 Apr 2025 10:04:02 UTC
Severity: normal
Tags: patch
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #26 received at submit <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:
> [ Ideally, this function would be replaced with one which doesn't return
> just `t` but an actual "handle" on the hash-table slot, so that we can
> then access that slot without redoing the key lookup. It would allow
> doing thing like `push` or `incf` on a hash-table entry without
> looking up the key twice.
> But doing so without allocating an object is hard with the current
> hash-table design (and would come with its own downsides). ]
A micro-optimization could be for the hash table to remember the last
key lookup, so that something like this hits a fast path for the second
lookup of the same key:
(when (hash-table-contains-p key table)
(push 'x (gethash table key)))
This bug report was last modified 12 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.