paulmillr / readdirp

Recursive version of fs.readdir with streaming api.
https://paulmillr.com
MIT License
378 stars 51 forks source link

Load picomatch lazily #158

Open fabiospampinato opened 4 years ago

fabiospampinato commented 4 years ago

Picomatch seems to account for most of the loading time of readdirp:

image

I was looking into potential optimizations, and in my app I don't need to pass a glob to readdirp so still having to pay the cost for loading picomatch seems nonoptimal.

I think picomatch should be loaded lazily only if/when needed.

paulmillr commented 4 years ago

Do you really care about 2ms? Why?

fabiospampinato commented 4 years ago

Milliseconds add up 🤷‍♂️ 2ms aren't the end of the world, but it could take maybe 10ms in a low end device, and 20 of these tiny optimizations will add up to 40~200ms eventually which at startup especially will make a difference.

I can submit a PR for this if you like.

paulmillr commented 4 years ago

The real question here is why are you using readdirp in a browser. Eliminating it from your build would achieve the result, no?

fabiospampinato commented 4 years ago

It's a browser but it's a node.js app at the same time, i.e. I'm using Electron.

lydell commented 2 years ago

FYI picomatch was removed in https://github.com/paulmillr/readdirp/commit/703dee9f823f74fd990b503df52652f397759b1f (not released yet)