mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Refactor package_qualified_imported_modules in load
This commit is contained in:
parent
eea2196c30
commit
9df5fb7092
2 changed files with 13 additions and 13 deletions
|
@ -5353,19 +5353,10 @@ fn parse<'a>(
|
|||
// We always need to send these, even if deps is empty,
|
||||
// because the coordinator thread needs to receive this message
|
||||
// to decrement its "pending" count.
|
||||
let mut package_qualified_imported_modules = MutSet::default();
|
||||
for (pq_module_name, module_id) in &deps_by_name {
|
||||
match pq_module_name {
|
||||
PackageQualified::Unqualified(_) => {
|
||||
package_qualified_imported_modules
|
||||
.insert(PackageQualified::Unqualified(*module_id));
|
||||
}
|
||||
PackageQualified::Qualified(shorthand, _) => {
|
||||
package_qualified_imported_modules
|
||||
.insert(PackageQualified::Qualified(shorthand, *module_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
let package_qualified_imported_modules = deps_by_name
|
||||
.iter()
|
||||
.map(|(pq_module_name, module_id)| pq_module_name.map_module(|_| *module_id))
|
||||
.collect();
|
||||
|
||||
// SAFETY: By this point we've already incrementally verified that there
|
||||
// are no UTF-8 errors in these bytes. If there had been any UTF-8 errors,
|
||||
|
|
|
@ -462,6 +462,15 @@ impl<'a, T> PackageQualified<'a, T> {
|
|||
PackageQualified::Qualified(_, name) => name,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_module<B>(&self, f: impl FnOnce(&T) -> B) -> PackageQualified<'a, B> {
|
||||
match self {
|
||||
PackageQualified::Unqualified(name) => PackageQualified::Unqualified(f(name)),
|
||||
PackageQualified::Qualified(package, name) => {
|
||||
PackageQualified::Qualified(package, f(name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue