New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Linear glob match #4094 #4579

wants to merge 1 commit into
base: master


None yet
3 participants
Copy link

HazemSamir commented Dec 6, 2017

As Noted in #4094 that glob expansion is exponential. A near linear implementation is discussed in this article on glob expansion in various shells and platforms.

Changes in wildcard.cpp:

The function that is responsible for this behavior is wildcard_match and its wildcard_match_internal which matches the wildcard recursively with the string. I changed it to the near linear implementation discussed in the article.

The wildcard "**" is not affected by this function because wildcard_expand_string is the one that is responsible for it and it is still doing it recursively.

tested using:

cd (mktemp -d)
touch (printf 'a%.0s' (seq 100))
for n in (seq 1 10)
   set -l pattern (printf 'a*%.0s' (seq $n))b
   time fish -c "echo $pattern"
n (a*) User time exponential User time linear
1 0.01 0.008
2 0.00 0.000
3 0.00 0.004
4 0.03 0.008
5 0.57 0.004
6 9.13 0.004
7 126.32 0.004
8 1521.75 0.008
9 16055.30 0.008
10 152573.24 0.004

Fixes issue #4094


This comment has been minimized.

Copy link

ridiculousfish commented Dec 11, 2017

Reviewed, this looks awesome!! Merged as c45d4ab.

ridiculousfish added a commit that referenced this pull request Dec 11, 2017

Add glob changes to CHANGELOG
This records the glob changes from #4579 in the changelog

This comment has been minimized.

Copy link

ridiculousfish commented Dec 11, 2017

Noted in changelog as c077aae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment