Changeset b4d2b3b


Ignore:
Timestamp:
Jul 6, 2023, 4:32:01 PM (13 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
2fe64ba
Parents:
8f31be6
Message:

Some cases in linkReferencesToTypes: It always hits one or both of the conditionals, so moving the mutation outside is a slight optimization and also reduces noise.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/LinkReferenceToTypes.cpp

    r8f31be6 rb4d2b3b  
    8080ast::EnumInstType const * LinkTypesCore::postvisit( ast::EnumInstType const * type ) {
    8181        ast::EnumDecl const * decl = symtab.lookupEnum( type->name );
     82        ast::EnumInstType * mut = ast::mutate( type );
    8283        // It's not a semantic error if the enum is not found, just an implicit forward declaration.
    8384        if ( decl ) {
    8485                // Just linking in the node.
    85                 auto mut = ast::mutate( type );
    8686                mut->base = decl;
    87                 type = mut;
    8887        }
    8988        if ( !decl || !decl->body ) {
    90                 auto mut = ast::mutate( type );
    9189                forwardEnums[ mut->name ].push_back( mut );
    92                 type = mut;
    93         }
    94         return type;
     90        }
     91        return mut;
    9592}
    9693
    9794ast::StructInstType const * LinkTypesCore::postvisit( ast::StructInstType const * type ) {
    9895        ast::StructDecl const * decl = symtab.lookupStruct( type->name );
     96        ast::StructInstType * mut = ast::mutate( type );
    9997        // It's not a semantic error if the struct is not found, just an implicit forward declaration.
    10098        if ( decl ) {
    10199                // Just linking in the node.
    102                 auto mut = ast::mutate( type );
    103100                mut->base = decl;
    104                 type = mut;
    105101        }
    106102        if ( !decl || !decl->body ) {
    107                 auto mut = ast::mutate( type );
    108103                forwardStructs[ mut->name ].push_back( mut );
    109                 type = mut;
    110         }
    111         return type;
     104        }
     105        return mut;
    112106}
    113107
    114108ast::UnionInstType const * LinkTypesCore::postvisit( ast::UnionInstType const * type ) {
    115109        ast::UnionDecl const * decl = symtab.lookupUnion( type->name );
     110        ast::UnionInstType * mut = ast::mutate( type );
    116111        // It's not a semantic error if the union is not found, just an implicit forward declaration.
    117112        if ( decl ) {
    118113                // Just linking in the node.
    119                 auto mut = ast::mutate( type );
    120114                mut->base = decl;
    121                 type = mut;
    122115        }
    123116        if ( !decl || !decl->body ) {
    124                 auto mut = ast::mutate( type );
    125117                forwardUnions[ mut->name ].push_back( mut );
    126                 type = mut;
    127         }
    128         return type;
     118        }
     119        return mut;
    129120}
    130121
Note: See TracChangeset for help on using the changeset viewer.