Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

@HazemSamir
Copy link
Contributor

@HazemSamir 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"
end
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

@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Dec 11, 2017

Reviewed, this looks awesome!! Merged as c45d4ab.

Loading

ridiculousfish added a commit that referenced this issue Dec 11, 2017
This records the glob changes from #4579 in the changelog
@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Dec 11, 2017

Noted in changelog as c077aae

Loading

@faho faho added this to the fish-3.0 milestone Jun 13, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants