diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2015-08-01 16:52:22 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2015-08-08 13:55:48 -0700 |
commit | b55c13f275519d68ea24ecd08d4bd0f426b94722 (patch) | |
tree | 5a45037676886320f51799daa4e3f72f6d516f14 /src/wildcard.cpp | |
parent | 761651d410ffca7627fdc6180698bdd9d56553b0 (diff) |
Turn on the new wildcard expander
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 96fba5a7..e8e1567c 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -1271,23 +1271,15 @@ static int wildcard_expand_internal(const wchar_t *wc, static int wildcard_expand(const wchar_t *wc, - const wchar_t *base_dir, + const wcstring &base_dir, expand_flags_t flags, std::vector<completion_t> *out) { assert(out != NULL); size_t c = out->size(); - - /* Make a set of used completion strings so we can do fast membership tests inside wildcard_expand_internal. Otherwise wildcards like '**' are very slow, because we end up with an N^2 membership test. - */ - std::set<wcstring> completion_set; - for (std::vector<completion_t>::const_iterator iter = out->begin(); iter != out->end(); ++iter) - { - completion_set.insert(iter->completion); - } - - std::set<file_id_t> visited_files; - int res = wildcard_expand_internal(wc, base_dir, flags, out, completion_set, visited_files); + + wildcard_expander_t expander(flags, out); + expander.expand(base_dir, wc); if (flags & ACCEPT_INCOMPLETE) { @@ -1310,7 +1302,14 @@ static int wildcard_expand(const wchar_t *wc, } } } - return res; + if (expander.interrupted()) + { + return -1; + } + else + { + return expander.added() ? 1 : 0; + } } int wildcard_expand_string(const wcstring &wc, const wcstring &base_dir, expand_flags_t flags, std::vector<completion_t> *output) @@ -1321,5 +1320,5 @@ int wildcard_expand_string(const wcstring &wc, const wcstring &base_dir, expand_ { return 0; } - return wildcard_expand(wc.c_str(), base_dir.c_str(), flags, output); + return wildcard_expand(wc.c_str(), base_dir, flags, output); } |