Pre: use ..Default approach for use_as_template and make_receptacle.
I decided this was more efficient (no temporary attributes and mutability) and less confusing.
This commit is contained in:
parent
98ac559894
commit
79ccd818f3
1 changed files with 18 additions and 20 deletions
|
@ -221,31 +221,29 @@ impl ConjoiningClauses {
|
||||||
/// Cloning.
|
/// Cloning.
|
||||||
impl ConjoiningClauses {
|
impl ConjoiningClauses {
|
||||||
fn make_receptacle(&self) -> ConjoiningClauses {
|
fn make_receptacle(&self) -> ConjoiningClauses {
|
||||||
let mut concrete = ConjoiningClauses::default();
|
ConjoiningClauses {
|
||||||
concrete.empty_because = self.empty_because.clone();
|
alias_counter: self.alias_counter.clone(),
|
||||||
|
empty_because: self.empty_because.clone(),
|
||||||
concrete.alias_counter = self.alias_counter.clone();
|
input_variables: self.input_variables.clone(),
|
||||||
concrete.input_variables = self.input_variables.clone();
|
value_bindings: self.value_bindings.clone(),
|
||||||
concrete.value_bindings = self.value_bindings.clone();
|
known_types: self.known_types.clone(),
|
||||||
concrete.known_types = self.known_types.clone();
|
extracted_types: self.extracted_types.clone(),
|
||||||
concrete.extracted_types = self.extracted_types.clone();
|
..Default::default()
|
||||||
|
}
|
||||||
concrete
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make a new CC populated with the relevant variable associations in this CC.
|
/// Make a new CC populated with the relevant variable associations in this CC.
|
||||||
/// The CC shares an alias count with all of its copies.
|
/// The CC shares an alias count with all of its copies.
|
||||||
fn use_as_template(&self, vars: &BTreeSet<Variable>) -> ConjoiningClauses {
|
fn use_as_template(&self, vars: &BTreeSet<Variable>) -> ConjoiningClauses {
|
||||||
let mut template = ConjoiningClauses::default();
|
ConjoiningClauses {
|
||||||
template.alias_counter = self.alias_counter.clone(); // Rc ftw.
|
alias_counter: self.alias_counter.clone(),
|
||||||
template.empty_because = self.empty_because.clone();
|
empty_because: self.empty_because.clone(),
|
||||||
|
input_variables: self.input_variables.intersection(vars).cloned().collect(),
|
||||||
template.input_variables = self.input_variables.intersection(vars).cloned().collect();
|
value_bindings: self.value_bindings.with_intersected_keys(&vars),
|
||||||
template.value_bindings = self.value_bindings.with_intersected_keys(&vars);
|
known_types: self.known_types.with_intersected_keys(&vars),
|
||||||
template.known_types = self.known_types.with_intersected_keys(&vars);
|
extracted_types: self.extracted_types.with_intersected_keys(&vars),
|
||||||
template.extracted_types = self.extracted_types.with_intersected_keys(&vars);
|
..Default::default()
|
||||||
|
}
|
||||||
template
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue