tiny-glob icon indicating copy to clipboard operation
tiny-glob copied to clipboard

Very slow in a directory with nested directories and one-level pattern

Open mrmlnc opened this issue 5 years ago • 2 comments

Versions

  • Windows 10 (17763)
  • NVMe (Samsung MZVLB512HAJQ)
  • Node.js 12.0.0

A directory tree

directory
  - file.txt
  - node_modules

Reproduce steps

const tg = require('tiny-glob/sync');

console.time('tiny-glob');
const entries = tg('directory/*');
console.timeEnd('tiny-glob');

console.dir(entries, { colors: true });

Current behaviour

The walk function is called for each directory inside the root directory. And it takes 256ms.

Expected behaviour

One the walk function call. And… it takes around 2-5ms.

mrmlnc avatar May 22 '19 06:05 mrmlnc

Hey, thanks~!

If I understand correctly, you're saying that directory/* is behaving like directory/**, right? If so, yes, that definitely should be fixed

lukeed avatar May 22 '19 06:05 lukeed

Probably not. With directory/* pattern result is correctly (only files from the first level of the directory directory), but inside we read all the subdirectories (like with dirrctory/** pattern).

Looks like edge case. With directory/*.json pattern works correctly.

mrmlnc avatar May 22 '19 07:05 mrmlnc