This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: Why do we nreverse CLASSTYPE_TAGS
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Matt Austern <austern at apple dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc at gcc dot gnu dot org, jason at redhat dot com
- Date: 24 Mar 2003 13:02:26 -0800
- Subject: Re: C++: Why do we nreverse CLASSTYPE_TAGS
- References: <B9C5B416-5E32-11D7-8995-00039390D9E0@apple.com>
On Mon, 2003-03-24 at 11:56, Matt Austern wrote:
> On Monday, March 24, 2003, at 11:21 AM, Mark Mitchell wrote:
>
> >> OK, I'll experiment with that approach. What threasold would you put
> >> for "lots"?
> >
> > I dunno. Probably 10 or so, to start. With fewer than that, hashing
> > can't possibly be a win.
>
> How expensive is the hash function? Unless it's pretty extreme, I'd be
> surprised if you needed to get all the way to 10 to get a win.
Well, it's a hash *function*; you get to make an extra function call.
As opposed to roughly:
for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x))
if (DECL_NAME (x) == name)
break;
I guess it depends on how many cycles, exactly.
Hash tables take up a fair amount of memory; if we make a new hash table
per type, we'll pay a bit. The other thing to do would be to make one
hash table for all classes: the key being the pair <class, field_name>.
Maybe that's the best of both worlds.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com