Skip to content

Have the ChangeTracker filter out edits that are no-ops #38123

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

Merged
merged 6 commits into from
Apr 23, 2020

Conversation

DanielRosenwasser
Copy link
Member

Fixes #22912

@DanielRosenwasser DanielRosenwasser changed the title Filter out edits that are no-ops in 'organize imports' Have the change-tracker filter out edits that are no-ops Apr 23, 2020
@DanielRosenwasser DanielRosenwasser changed the title Have the change-tracker filter out edits that are no-ops Have the ChangeTracker filter out edits that are no-ops Apr 23, 2020
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

I'm kind of embarrassed by how simple this turned out to be.

LGTM, except for my perf comment.

@DanielRosenwasser
Copy link
Member Author

Honestly, this is a great practice in premature optimization, but I feel better knowing it's not much worse off. Summary:

  • There's a fast path for pure additions, deletions, other general differences - those are always kept.
  • When we need to check the contents, we don't allocate or traverse the whole file.
  • We don't allocate ChangeRanges for non-applicable changes or for files if they're empty or useless.

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.

Organize imports always returns an edit, even when imports are already sorted
3 participants