Much faster

This commit is contained in:
elvis
2025-09-05 14:09:00 +02:00
parent fd33af456a
commit bf8bfd0d17
2 changed files with 4 additions and 7 deletions

View File

@ -2,7 +2,7 @@
name = "reactionsystems" name = "reactionsystems"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
exclude = ["*.system", "*.experiment", "/testing/", "*.serial"] exclude = ["*.system", "*.experiment", "/testing/", "*.serial", "*.dot", "*.trace", "*.svg"]
[build-dependencies] [build-dependencies]
lalrpop = "0.22" lalrpop = "0.22"

View File

@ -80,9 +80,7 @@ impl BasicSet for Set {
// returns the new set a \cup b // returns the new set a \cup b
fn union(&self, other: &Self) -> Self { fn union(&self, other: &Self) -> Self {
let mut ret: Self = other.clone(); self.iter().chain(other.iter()).cloned().collect::<Vec<_>>().into()
ret.identifiers.extend(self.identifiers.iter());
ret
} }
fn push(&mut self, other: &Self) { fn push(&mut self, other: &Self) {
@ -355,9 +353,8 @@ impl BasicSet for PositiveSet {
/// ☞ The operation cannot fail, so we prefer self elements to other, /// ☞ The operation cannot fail, so we prefer self elements to other,
/// but if the reaction system is consistent there wont be any problem. /// but if the reaction system is consistent there wont be any problem.
fn union(&self, other: &Self) -> Self { fn union(&self, other: &Self) -> Self {
let mut ret: Self = other.clone(); self.iter().chain(other.iter()).map(|(a, b)| (*a, *b))
ret.identifiers.extend(self.identifiers.iter()); .collect::<Vec<_>>().into()
ret
} }
fn push(&mut self, other: &Self) { fn push(&mut self, other: &Self) {