Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StringIntern for Item and Property Functions. #9024

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Build/Evaluation/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3315,7 +3315,7 @@ internal string Receiver
ProjectErrorUtilities.ThrowInvalidProject(elementLocation, "InvalidFunctionStaticMethodSyntax", expressionFunction, String.Empty);
}

var typeName = expressionRoot.Slice(1, typeEndIndex - 1).ToString();
var typeName = Strings.WeakIntern(expressionRoot.Slice(1, typeEndIndex - 1));
var methodStartIndex = typeEndIndex + 1;

if (expressionRoot.Length > methodStartIndex + 2 && expressionRoot[methodStartIndex] == ':' && expressionRoot[methodStartIndex + 1] == ':')
Expand Down Expand Up @@ -3373,7 +3373,7 @@ internal string Receiver
var rootEndIndex = expressionRoot.IndexOf('.');

// If this is an instance function rather than a static, then we'll capture the name of the property referenced
var functionReceiver = expressionRoot.Slice(0, rootEndIndex).Trim().ToString();
var functionReceiver = Strings.WeakIntern(expressionRoot.Slice(0, rootEndIndex).Trim());

// If propertyValue is null (we're not recursing), then we're expecting a valid property name
if (propertyValue == null && !IsValidPropertyName(functionReceiver))
Expand Down
11 changes: 4 additions & 7 deletions src/Build/Evaluation/ExpressionShredder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ internal static List<ItemExpressionCapture> GetReferencedItemExpressions(string

// Grab the name, but continue to verify it's a well-formed expression
// before we store it.
string name = expression.Substring(startOfName, i - startOfName);

// return the item that we're working with
string itemName = name;
string itemName = Microsoft.NET.StringTools.Strings.WeakIntern(expression.AsSpan(startOfName, i - startOfName));

SinkWhitespace(expression, ref i);
bool transformOrFunctionFound = true;
Expand Down Expand Up @@ -251,10 +248,10 @@ internal static List<ItemExpressionCapture> GetReferencedItemExpressions(string
subExpressions = new List<ItemExpressionCapture>();
}

// Create an expression capture that encompases the entire expression between the @( and the )
// Create an expression capture that encompasses the entire expression between the @( and the )
// with the item name and any separator contained within it
// and each transform expression contained within it (i.e. each ->XYZ)
ItemExpressionCapture expressionCapture = new ItemExpressionCapture(startPoint, endPoint - startPoint, expression.Substring(startPoint, endPoint - startPoint), itemName, separator, separatorStart, transformExpressions);
ItemExpressionCapture expressionCapture = new ItemExpressionCapture(startPoint, endPoint - startPoint, Microsoft.NET.StringTools.Strings.WeakIntern(expression.AsSpan(startPoint, endPoint - startPoint)), itemName, separator, separatorStart, transformExpressions);
subExpressions.Add(expressionCapture);

continue;
Expand Down Expand Up @@ -601,7 +598,7 @@ private static ItemExpressionCapture SinkItemFunctionExpression(string expressio

if (endFunctionArguments > startFunctionArguments)
{
capture.FunctionArguments = expression.Substring(startFunctionArguments, endFunctionArguments - startFunctionArguments);
capture.FunctionArguments = Microsoft.NET.StringTools.Strings.WeakIntern(expression.AsSpan(startFunctionArguments, endFunctionArguments - startFunctionArguments));
}

return capture;
Expand Down