This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [cxx-conversion] various hash tables, part 1/2
- From: Diego Novillo <dnovillo at google dot com>
- To: Lawrence Crowl <crowl at googlers dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 3 Dec 2012 14:15:06 -0500
- Subject: Re: [cxx-conversion] various hash tables, part 1/2
- References: <CAGqM8fbWKr4wpVWzvZBR8baZbGtnKgjnntgjHzrrOvXOk6B34A@mail.gmail.com>
On Sat, Dec 1, 2012 at 8:47 PM, Lawrence Crowl <crowl@googlers.com> wrote:
> +inline bool
> +attribute_hasher::equal (const value_type *spec, const compare_type *str)
> +{
> + return (!strncmp (spec->name, str->str, str->length)
I have a slight preference for strncmp() == 0. It's easier to read (I
realize that you are just cut-n-pasting old code here :)
> @@ -76,13 +82,11 @@ bitmap_descriptor (const char *file, int
> loc.function = function;
> loc.line = line;
>
> - if (!bitmap_desc_hash)
> - bitmap_desc_hash = htab_create (10, hash_descriptor, eq_descriptor, NULL);
> + if (!bitmap_desc_hash.is_created ())
> + bitmap_desc_hash.create (10);
>
> - slot = (struct bitmap_descriptor **)
> - htab_find_slot_with_hash (bitmap_desc_hash, &loc,
> - htab_hash_pointer (file) + line,
> - INSERT);
> + slot = bitmap_desc_hash
> + .find_slot_with_hash (&loc, htab_hash_pointer (file) + line, INSERT);
I'd rather split the argument list here.
> }
>
> -static int
> -htab_cu_eq (const void *of1, const void *of2)
> +inline bool
> +cu_hash_table_entry_hasher::equal (const value_type *entry1,
> + const compare_type *entry2)
No static?
> -static hashval_t
> -ttypes_filter_hash (const void *pentry)
> +inline hashval_t
> +ttypes_filter_hasher::hash (const value_type *entry)
> {
> - const struct ttypes_filter *entry = (const struct ttypes_filter *) pentry;
> return TREE_HASH (entry->t);
The patch seems to have changed the types here. Is it value_type or
ttypes_filter?
Looks OK otherwise.
Diego.