Skip to content

fix(node): reduce deepReadDirSync runtime complexity #7910

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 1 commit into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export function deepReadDirSync(targetDir: string): string[] {
const itemAbsPath = path.join(currentDirAbsPath, itemName);

if (fs.statSync(itemAbsPath).isDirectory()) {
return [...absPaths, ...deepReadCurrentDir(itemAbsPath)];
return absPaths.concat(deepReadCurrentDir(itemAbsPath));
Copy link
Member Author

Choose a reason for hiding this comment

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

Depending on how we transpile this, it might already be transpiled to something like [].concat(abspaths, [deppread]), doesn't hurt to omit the empty array though

Copy link
Member

Choose a reason for hiding this comment

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

We transpile to es6, so the spread operator is kept.

}

return [...absPaths, itemAbsPath];
absPaths.push(itemAbsPath);
return absPaths;
}, []);
};

Expand Down