diff options
Diffstat (limited to 'gcc/lto-streamer.c')
-rw-r--r-- | gcc/lto-streamer.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index 5ff8a6d..8932038 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -253,28 +253,33 @@ print_lto_report (const char *s) #ifdef LTO_STREAMER_DEBUG -static htab_t tree_htab; - struct tree_hash_entry { tree key; intptr_t value; }; -static hashval_t -hash_tree (const void *p) +struct tree_entry_hasher : typed_noop_remove <tree_hash_entry> +{ + typedef tree_hash_entry value_type; + typedef tree_hash_entry compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +inline hashval_t +tree_entry_hasher::hash (const value_type *e) { - const struct tree_hash_entry *e = (const struct tree_hash_entry *) p; return htab_hash_pointer (e->key); } -static int -eq_tree (const void *p1, const void *p2) +inline bool +tree_entry_hasher::equal (const value_type *e1, const compare_type *e2) { - const struct tree_hash_entry *e1 = (const struct tree_hash_entry *) p1; - const struct tree_hash_entry *e2 = (const struct tree_hash_entry *) p2; return (e1->key == e2->key); } + +static hash_table <tree_hash_entry> tree_htab; #endif /* Initialization common to the LTO reader and writer. */ @@ -289,7 +294,7 @@ lto_streamer_init (void) streamer_check_handled_ts_structures (); #ifdef LTO_STREAMER_DEBUG - tree_htab = htab_create (31, hash_tree, eq_tree, NULL); + tree_htab.create (31); #endif } @@ -324,8 +329,7 @@ lto_orig_address_map (tree t, intptr_t orig_t) ent.key = t; ent.value = orig_t; - slot - = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, INSERT); + slot = tree_htab.find_slot (&ent, INSERT); gcc_assert (!*slot); *slot = XNEW (struct tree_hash_entry); **slot = ent; @@ -342,8 +346,7 @@ lto_orig_address_get (tree t) struct tree_hash_entry **slot; ent.key = t; - slot - = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, NO_INSERT); + slot = tree_htab.find_slot (&ent, NO_INSERT); return (slot ? (*slot)->value : 0); } @@ -357,11 +360,10 @@ lto_orig_address_remove (tree t) struct tree_hash_entry **slot; ent.key = t; - slot - = (struct tree_hash_entry **) htab_find_slot (tree_htab, &ent, NO_INSERT); + slot = tree_htab.find_slot (&ent, NO_INSERT); gcc_assert (slot); free (*slot); - htab_clear_slot (tree_htab, (PTR *)slot); + tree_htab.clear_slot (slot); } #endif |