Skip to content

Fast path when evaluating string.PadLeft(int, char)#5226

Merged
Forgind merged 1 commit intodotnet:masterfrom
KirillOsenkov:dev/kirillo/padLeftChar
Apr 7, 2020
Merged

Fast path when evaluating string.PadLeft(int, char)#5226
Forgind merged 1 commit intodotnet:masterfrom
KirillOsenkov:dev/kirillo/padLeftChar

Conversation

@KirillOsenkov
Copy link
Copy Markdown
Member

The previous fast path was only expecting the args of int and string, but was actually given int and char. So the fast path was not taken for expressions such as:

$(VersionSuffixBuildOfTheDay.PadLeft(2, $([System.Convert]::ToChar(0))))

Try to interpret int and char as int and string, this ensures the fast path is taken.

This fixes a first-chance MissingMethodException.

The previous fast path was only expecting the args of int and string, but was actually given int and char. So the fast path was not taken for expressions such as:

$(VersionSuffixBuildOfTheDay.PadLeft(2, $([System.Convert]::ToChar(`0`))))

Try to interpret int and char as int and string, this ensures the fast path is taken.

This fixes a first-chance MissingMethodException.
}

arg1 = args[1] as string;
if (arg1 == null && args[1] is char ch)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not affecting this PR: At some point somebody has to extract all this C# interpretation code outside of Expander.cs and into its own class :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point somebody should rewrite the Evaluator and kill this class altogether ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They mythical "some point" when everything is made nice :)

@rainersigwald rainersigwald added this to the MSBuild 16.6 Preview 3 milestone Apr 7, 2020
@Forgind Forgind merged commit 7a0df31 into dotnet:master Apr 7, 2020
@KirillOsenkov KirillOsenkov deleted the dev/kirillo/padLeftChar branch April 7, 2020 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants