Re: [PATCH 4/4] gdb: change regcache list to be a map

Tom Tromey
2020-08-10T19:15:29Z

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

A bit late on this thread, but OTOH nothing too urgent to say...

Simon> Note: In hash_target_ptid, I am combining hash values from std::hash by
Simon> summing them. I don't think it's ideal, since std::hash is just the
Simon> identity function for base types. But I don't know what would be better
Simon> to reduce the change of collisions. If anybody has a better idea, I'd
Simon> be interested.

You can use fast_hash iteratively. It may not matter though.

Simon> +/* Hash function for target_ptid. */
Simon> +
Simon> +struct hash_target_ptid
Simon> +{
Simon> + size_t operator() (const target_ptid &val) const
Simon> + {

It seems to me that for types that have a single "natural" hash, or a
useful "canonical" hash (i.e., a hash we'd be likely to want to use by
default in the normal case), we could specialize std::hash. For
example, this code could do that.

Tom