Skip to content

Commit

Permalink
docs: todo about set intersection
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed May 24, 2024
1 parent 10a9c73 commit 8cbf423
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/shared/local/moveDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const getMatches = (status: StatusRow[]): AddedAndDeletedFilenames => {
const addedBasenames = new Set(addedFilenames.map((filename) => path.basename(filename)));
const deletedBasenames = new Set(deletedFilenames.map((filename) => path.basename(filename)));

// TODO: when node 22 is everywhere, we can use Set.prototype.intersection
// Again, we filter over the deleted files first and exit early if there are no filename matches
const deletedFilenamesWithMatches = new Set(deletedFilenames.filter((f) => addedBasenames.has(path.basename(f))));
if (!deletedFilenamesWithMatches.size) return emptyResult;
Expand Down

0 comments on commit 8cbf423

Please sign in to comment.