I've had to make a potentially related optimization in a reg-ex engine before, so I'll try to describe an optimization in case it could be of value for SE:
When evaluating *, a reg-ex engine typically keeps track of where to back up to if the stuff following the * fails to match. But it is possible to back up more efficiently, to avoid unnecesssary re-processing -- the optimization can potentially change a mismatch from O(N^2) to O(N) performance.
Since there are many wildcards to evaluate, it could be that the total cost is coming out to roughly O(M*(N^2)*K) where M is the number of files in the workspace, N is the length of the file name, and K is the number of wildcard expressions. If the back up is not already optimized, then optimizing it might reduce the cost to roughly O(M*N*K) which would scale better.
Attached is an sample of the optimization -- see Flatfile.cpp
line 319 (in the
cmpsort function). Flatfile.cpp is part of the source to my EnhProj macro+DLL (see
here). (I tried to paste just the function, for convenience, but the forum doesn't like some keyword in the text and returns HTTP errors, so I just attached the whole file).