Skip to content

Commit

Permalink
Optimization to hot path method
Browse files Browse the repository at this point in the history
- Replace HasFlag() calls with bitwise checks to avoid garbage generation in FindUserDefinedSymbol which gets called extremely frequently. On one test project this reduced garbage generation for a compile from 211MB to 128MB. This also speeds up the function quite a bit (367ms -> 153ms in the same test case as above) so in some cases it can help compile time on large scripts.
  • Loading branch information
MerlinVR committed Jan 30, 2021
1 parent 26f9419 commit b8013fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/UdonSharp/Editor/UdonSharpSymbolTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ public SymbolDefinition FindUserDefinedSymbol(string symbolName)
{
SymbolDefinition symbolDefinition = currentTable.symbolDefinitions[i];

if (!symbolDefinition.declarationType.HasFlag(SymbolDeclTypeFlags.Internal) &&
(!currentTable.IsGlobalSymbolTable || !symbolDefinition.declarationType.HasFlag(SymbolDeclTypeFlags.MethodParameter)) && // Method parameters are declared globally, but only valid in their current local scope
if ((symbolDefinition.declarationType & SymbolDeclTypeFlags.Internal) == 0 &&
(!currentTable.IsGlobalSymbolTable || (symbolDefinition.declarationType & SymbolDeclTypeFlags.MethodParameter) == 0) && // Method parameters are declared globally, but only valid in their current local scope
symbolDefinition.symbolOriginalName == symbolName)
{
return symbolDefinition;
Expand Down

0 comments on commit b8013fc

Please sign in to comment.