Skip to content

Commit

Permalink
Make Namespace PartialEq. Add missing filter to optimize.
Browse files Browse the repository at this point in the history
By making `Namespace` `PartialEq`, we're able to re-add the original
filter to the `optimize` pass that ensures we don't unnecessarily
re-compile constants for the current module.
  • Loading branch information
mitchmindtree committed Apr 18, 2022
1 parent 9f868bb commit 2001d61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion sway-core/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ fn compile_constants(
}
}

for ns in namespace.get_all_imported_modules() {
for ns in namespace
.get_all_imported_modules()
.filter(|&ns| ns == namespace)
{
compile_constants(context, module, ns, true)?;
}

Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/semantic_analysis/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type UseAliases = im::HashMap<String, Ident>;
/// importing.
///
/// The namespace is constructed during type checking.
#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Namespace {
// This is a BTreeMap because we rely on its ordering being consistent. See
// [Namespace::get_all_declared_symbols] -- we need that iterator to have a deterministic
Expand Down Expand Up @@ -855,7 +855,7 @@ impl Namespace {
type TraitMapInner = im::Vector<((TraitName, TypeInfo), TraitMethods)>;
type TraitMethods = im::HashMap<String, TypedFunctionDeclaration>;

#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct TraitMap {
trait_map: TraitMapInner,
}
Expand Down

0 comments on commit 2001d61

Please sign in to comment.