Could probably be optimized a bit more, would only need to scan the directory once rather than twice (does similar scan in workspacesFilesUris). But for now it is a bit better, if you can see anything else that can be optimized.
// before
getScannableFilesUris took: 4 secs, 157 ms, 419 μs, and 8 hnsecs
getScannableFilesUris took: 5 secs, 893 ms, 271 μs, and 5 hnsecs
getScannableFilesUris took: 4 secs, 176 ms, 467 μs, and 8 hnsecs
// after
getScannableFilesUris took: 650 ms, 965 μs, and 3 hnsecs
getScannableFilesUris took: 828 ms, 252 μs, and 3 hnsecs
getScannableFilesUris took: 699 ms and 415 μs
Could probably be optimized a bit more, would only need to scan the directory once rather than twice (does similar scan in workspacesFilesUris). But for now it is a bit better, if you can see anything else that can be optimized.