You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Use iterative fs.opendir for memory efficiency and early termination
Replace fs.readdir() with fs.opendir() async iterator:
- More memory efficient: doesn't allocate full array for large directories
- Early termination: stops reading if we collect 2x the limit (accounts for filtering)
- Proper cleanup: uses finally block to ensure dirHandle.close()
For huge directories (1000+ files), this prevents unnecessary memory allocation
when we only need the first 64 entries. The 2x multiplier ensures we read enough
entries to account for gitignore filtering and pattern matching.
0 commit comments