ls() sorting is expensive...
I was surprised to find that when profiling my app - I'm getting significant hangs with Path.ls()
I can see that you added .sorted() in https://github.com/mxcl/Path.swift/issues/58
First comment is that the doc is wrong - it states:
Same as the `ls` command ∴ output is ”shallow” and unsorted.
Profiling a running app, I'm seeing 0.6 seconds spent doing locale-specific sorting for a not-particularly-huge directory, and a surprisingly large cost for the compactMap()
Not sure what the right approach would be here. I'll probably add an unsorted_ls() command for my own use.
Possible options:
- Remove the comment that output is unsorted
- Flag that sorting can be expensive in the docs
- ListDirectoryOptions: add an unsorted option ??
- Add a separate unsorted command
Not sure how this happened but yeah docs are wrong. I can update the docs and we could certainly remove the sorted() for a major version bump.
I think removing as a default would be a good plan. Makes sense that it is a version bump.