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
Clean up ImportMap
#15181
Clean up ImportMap
#15181
Conversation
Also micro-optimizes fuzzy search.
e6d0ef3
to
5db0e1a
Compare
let mut all_indexed_values = FxHashSet::default(); | ||
while let Some((_, indexed_values)) = stream.next() { | ||
all_indexed_values.extend(indexed_values.iter().copied()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen #7912, but I couldn't reproduce the duplication and I don't really think it's possible due to how fst
works. Let me know if I'm missing anything.
SearchMode::Fuzzy => { | ||
let mut unchecked_query_chars = query_string.chars(); | ||
let mut mismatching_query_char = unchecked_query_chars.next(); | ||
|
||
for input_char in input.chars() { | ||
match mismatching_query_char { | ||
None => return true, | ||
Some(matching_query_char) if matching_query_char == input_char => { | ||
mismatching_query_char = unchecked_query_chars.next(); | ||
} | ||
_ => (), | ||
let mut input_chars = input.chars(); | ||
for query_char in query_string.chars() { | ||
if input_chars.find(|&it| it == query_char).is_none() { | ||
return false; | ||
} | ||
} | ||
mismatching_query_char.is_none() | ||
true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This micro-optimization is based on https://rust.godbolt.org/z/jvMcT783o
@bors r+ |
☀️ Test successful - checks-actions |
There are several things in
hir_def::import_map
that are never used. This PR removes them and restructures the code. Namely:Query::name_only
, because it's always true.ImportPath
and changesImportInfo
to only store items' name, which should reduce the memory consumption to some extent.SearchMode::Contains
forQuery
because it's never used.Query::assoc_items_only
andQuery::exclude_import_kinds
intoQuery::assoc_mode
, because the latter is never used besides filtering associated items out.Best reviewed one commit at a time. I made sure each commit passes full test suite. I can squash the first three commits if needed.