From 743c1f88c87428ba1472b95869fe08239c397634 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Tue, 9 May 2023 17:58:57 +0300 Subject: [PATCH] perf: Use memoized FindType instead of SourceFindType --- .../XamlGenerator/XamlFileGenerator.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 51df5ea1957c..76fa61506045 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -5457,7 +5457,7 @@ private string RewriteAttachedPropertyPath(string value) if (parts.Length == 2) { - var targetType = SourceFindType(parts[0]); + var targetType = FindType(parts[0]); if (targetType != null) { @@ -5912,25 +5912,21 @@ private void BuildChild(IIndentedStringBuilder writer, XamlMemberDefinition? own } else if (target != null) { - // This builds property setters for specified member setter. - var separatorIndex = target.IndexOf(".", StringComparison.Ordinal); - var elementName = target.Substring(0, separatorIndex); - var propertyName = target.Substring(separatorIndex + 1); - var ownerControl = GetControlOwner(owner?.Owner); - - // Attached properties need to be expanded using the namespace, otherwise the resolution will be - // performed at runtime at a higher cost. - propertyName = RewriteAttachedPropertyPath(propertyName); - if (ownerControl != null) { - + // This builds property setters for specified member setter. + var separatorIndex = target.IndexOf(".", StringComparison.Ordinal); + var elementName = target.Substring(0, separatorIndex); var targetElement = FindSubElementByName(ownerControl, elementName); if (targetElement != null) { + var propertyName = target.Substring(separatorIndex + 1); + // Attached properties need to be expanded using the namespace, otherwise the resolution will be + // performed at runtime at a higher cost. + propertyName = RewriteAttachedPropertyPath(propertyName); writer.AppendLineIndented($"new global::Windows.UI.Xaml.Setter(new global::Windows.UI.Xaml.TargetPropertyPath(this._{elementName}Subject, \"{propertyName}\"), "); var targetElementType = GetType(targetElement.Type);