From 44522dc2f2d4d0717b3d7e396db20f43f5a87b70 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 7 Jul 2020 12:09:00 -0700 Subject: [PATCH] Performance tweak The Visual Studio performance profiler showed the FormatDescriptor equality test being called quite a lot. The test was vs. null, so a simple change from "==" to "is" improved performance dramatically. Fixing the underlying issue with a better data structure is still important, but this provided a big boost with little effort. --- SourceGen/DataAnalysis.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SourceGen/DataAnalysis.cs b/SourceGen/DataAnalysis.cs index 0244079..e2816ac 100644 --- a/SourceGen/DataAnalysis.cs +++ b/SourceGen/DataAnalysis.cs @@ -360,7 +360,7 @@ namespace SourceGen { // If the target offset has a symbol assigned, use it. Otherwise, try to // find something nearby that might be more appropriate. int origTargetOffset = targetOffset; - if (mAnattribs[targetOffset].Symbol == null) { + if (mAnattribs[targetOffset].Symbol is null) { if (mAnalysisParams.SeekNearbyTargets) { targetOffset = FindAlternateTarget(srcOffset, targetOffset); } @@ -392,7 +392,7 @@ namespace SourceGen { int scanOffset = targetOffset; while (--scanOffset >= 0) { FormatDescriptor dfd = mAnattribs[scanOffset].DataDescriptor; - if (dfd != null) { + if (!(dfd is null)) { if (scanOffset + dfd.Length > targetOffset) { // Found a descriptor that encompasses target offset. Adjust // target to point at the start of the region.