From: Richard Biener <richard.guenther@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: Enhance std::hash for pointers
Date: Fri, 08 May 2015 08:02:00 -0000 [thread overview]
Message-ID: <CAFiYyc2asQNBV2_1ezunOnVeVDpDzF5nBE4jyD+2t6PvsPJGYA@mail.gmail.com> (raw)
In-Reply-To: <554A751E.9030009@gmail.com>
On Wed, May 6, 2015 at 10:10 PM, François Dumont <frs.dumont@gmail.com> wrote:
> Hi
>
> Following Marc Glisse comment #4
> on:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65641 I would like to
> propose this enhancement to the hash functor for pointers. It simply gets
> rid of the irrelevant bits on pointers hash code based on memory alignment
> of the pointed type. The only drawback I can think of is that the type needs
> to be complete at std::hash instantiation time but is it really an issue ?
>
> IMO it is quite obvious that the resulting hash code will be better but
If you use a real hashing function that's not true. That is, something
else than GCCs pointer_hash (void *p) { return (uintptr_t)p >>3; }.
Richard.
> if anyone has a good method to prove it I can try to implement it. The test
> I have added in quality.cc is very basic and just reflect enhancement
> following Marc's comment.
>
> 2015-05-05 François Dumont <fdumont@gcc.gnu.org>
>
> * include/bits/functional_hash.h
> (std::__detail::_Lowest_power_of_two<size_t>): New.
> (std::hash<_Tp*>::operator()): Use latter.
> * testsuite/20_util/hash/quality.cc (pointer_quality_test): New.
>
> Tested under Linux x86_64.
>
> François
>
next prev parent reply other threads:[~2015-05-08 8:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 20:10 François Dumont
2015-05-08 8:02 ` Richard Biener [this message]
2015-05-08 20:18 ` François Dumont
2015-05-08 22:11 ` Christopher Jefferson
2015-05-11 21:06 ` François Dumont
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=CAFiYyc2asQNBV2_1ezunOnVeVDpDzF5nBE4jyD+2t6PvsPJGYA@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.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.
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).