diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-05-19 09:58:20 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-05-19 09:58:20 -0400 |
commit | c5709fc87131bea0013cb67cf80bdea6e238c918 (patch) | |
tree | e791a9ac038cb6cba6de2e837a6cd25f5e81cb61 /gcc | |
parent | ef8926d23a458560b8e9be1a76cf29ddcb87ec2a (diff) | |
download | gcc-c5709fc87131bea0013cb67cf80bdea6e238c918.zip gcc-c5709fc87131bea0013cb67cf80bdea6e238c918.tar.gz gcc-c5709fc87131bea0013cb67cf80bdea6e238c918.tar.bz2 |
c++: simplify norm_cache manipulation
We can avoid performing two norm_cache lookups during normalization of a
concept-id by allocating and inserting a norm_entry* before rather than
after the fact, which is simpler and cheaper.
gcc/cp/ChangeLog:
* constraint.cc (normalize_concept_check): Avoid having to do
two norm_cache lookups. Remove unnecessary early exit for an
ill-formed concept definition.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/constraint.cc | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index c81e024..8cf0f2d 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -774,38 +774,25 @@ normalize_concept_check (tree check, tree args, norm_info info) if (!norm_cache) norm_cache = hash_table<norm_hasher>::create_ggc (31); - norm_entry entry = {tmpl, targs, NULL_TREE}; - norm_entry **slot = nullptr; - hashval_t hash = 0; - bool insert = false; + norm_entry *entry = nullptr; if (!info.generate_diagnostics ()) { /* Cache the normal form of the substituted concept-id (when not diagnosing). */ - hash = norm_hasher::hash (&entry); - slot = norm_cache->find_slot_with_hash (&entry, hash, NO_INSERT); - if (slot) + norm_entry elt = {tmpl, targs, NULL_TREE}; + norm_entry **slot = norm_cache->find_slot (&elt, INSERT); + if (*slot) return (*slot)->norm; - insert = true; + entry = ggc_alloc<norm_entry> (); + *entry = elt; + *slot = entry; } - /* The concept may have been ill-formed. */ tree def = get_concept_definition (DECL_TEMPLATE_RESULT (tmpl)); - if (def == error_mark_node) - return error_mark_node; - info.update_context (check, args); tree norm = normalize_expression (def, targs, info); - if (insert) - { - /* Recompute SLOT since norm_cache may have been expanded during - the recursive call. */ - slot = norm_cache->find_slot_with_hash (&entry, hash, INSERT); - gcc_checking_assert (!*slot); - entry.norm = norm; - *slot = ggc_alloc<norm_entry> (); - **slot = entry; - } + if (entry) + entry->norm = norm; return norm; } |