Skip to content

Commit

Permalink
perf: Use memoized FindType instead of SourceFindType
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed May 9, 2023
1 parent 69095eb commit 743c1f8
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 743c1f8

Please sign in to comment.