Optimize extended glob
The extended glob algorithm is slow especially when more than one ** component appear in a pattern.
Maybe we can improve this by introducing a state-machine-based algorithm and avoiding repeated search on the same directory.
It may also make it possible to omit the duplicate path removal step after sorting the results, as the search algorithm no longer produces duplicate paths for the same path.
Done in r4147