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

Keep tracked files instead of refreshing list of untracked files #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thatsmydoing
Copy link

#27 introduced a massive performance regression with the recommended diff/diff setup. It effectively refreshes the list of untracked files for every unchanged file in the project.

Instead of constantly refreshing the tracked file list, it's better to get the list of tracked files once and we can simply check that a file is not in the list.

@@ -19,7 +19,7 @@ const untrackedFilename = "an-untracked-file.js";

const gitMocked: jest.MockedObjectDeep<typeof git> = jest.mocked(git);
gitMocked.getDiffFileList.mockReturnValue([filename]);
gitMocked.getUntrackedFileList.mockReturnValue([untrackedFilename]);
gitMocked.getTrackedFileList.mockReturnValue([filename, "file-with-dirty-index.js"]);
Copy link
Author

Choose a reason for hiding this comment

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

One of the tests also works with a file called file-with-dirty-index.js so we have to add it to the "tracked" list too.

@@ -117,11 +110,12 @@ const getProcessors = (
processorType: ProcessorType
): Required<Linter.Processor> => {
const staged = processorType === "staged";
const trackedFileSet = new Set(getTrackedFileList());
Copy link
Author

Choose a reason for hiding this comment

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

I'm wrapping this in a Set for faster lookups.

Comment on lines -34 to -35
const shouldRefresh =
!diffFileList.includes(filename) && !untrackedFileList.includes(filename);
Copy link
Author

Choose a reason for hiding this comment

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

This condition not only matches new files but actually all unchanged files, so instead of speeding things up this actually slows the entire lint process.

@TylerNRobertson
Copy link

Yeah noticing this as well, it makes the initial lint take really long to run, even when there is nothing to lint

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.

2 participants