dotnet/roslyn

Favor `Kind` check over type checking when appropriate

Open

#69.048 aperta il 15 lug 2023

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-CompilersArea-Performancehelp wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

image

Type checking here is 2.8% of CPU time. A good portion of it happens for symbols.

Would the following be more efficient?

if (symbol.Kind == SymbolKind.KindWeLookFor)
{
    return Unsafe.As<SymbolTypeToCastTo>(symbol);
}

Guida contributor