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

Fixing code fixes, part 4 #15551

Merged
merged 3 commits into from
Jul 10, 2023
Merged

Fixing code fixes, part 4 #15551

merged 3 commits into from
Jul 10, 2023

Conversation

psfinaki
Copy link
Member

@psfinaki psfinaki commented Jul 4, 2023

This PR:

@psfinaki psfinaki requested a review from a team as a code owner July 4, 2023 17:08
@psfinaki psfinaki merged commit eda1820 into dotnet:main Jul 10, 2023
@psfinaki psfinaki deleted the codefixes-13 branch July 10, 2023 21:08

// in a line like "... x -1 ...",
// squiggly goes for "x", not for "-", hence we search for "-"
let remainingText = $"{sourceText.GetSubText(context.Span.End)}"
Copy link
Member

Choose a reason for hiding this comment

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

$"{}" should never be a replacement for .ToString() in such case.
It's both worse performance wise as well as worse for readability (reader has to stop and figure out why the hell is string interpolation needed here).

Copy link
Member

Choose a reason for hiding this comment

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

Correction, even worse I guess - the previous code was carefully reading one character at a time from the Roslyn's SourceText.
The new code allocates for the full substring from position till end of the document, even though the algorithm itself only cares about immediate whitespaces after the position.

Copy link
Member Author

@psfinaki psfinaki Jul 11, 2023

Choose a reason for hiding this comment

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

Readability is debatable, performance - I guess not. I will fix this in the followup soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

In some cases, "Add missing equals" code fix breaks code even further
5 participants