From bf8bfd0d17ada119d7d3d643aece8e99531e3a35 Mon Sep 17 00:00:00 2001 From: elvis Date: Fri, 5 Sep 2025 14:09:00 +0200 Subject: [PATCH] Much faster --- Cargo.toml | 2 +- src/rsprocess/set.rs | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ac97b9..c388d58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "reactionsystems" version = "0.1.0" edition = "2024" -exclude = ["*.system", "*.experiment", "/testing/", "*.serial"] +exclude = ["*.system", "*.experiment", "/testing/", "*.serial", "*.dot", "*.trace", "*.svg"] [build-dependencies] lalrpop = "0.22" diff --git a/src/rsprocess/set.rs b/src/rsprocess/set.rs index a2be930..7f08302 100644 --- a/src/rsprocess/set.rs +++ b/src/rsprocess/set.rs @@ -80,9 +80,7 @@ impl BasicSet for Set { // returns the new set a \cup b fn union(&self, other: &Self) -> Self { - let mut ret: Self = other.clone(); - ret.identifiers.extend(self.identifiers.iter()); - ret + self.iter().chain(other.iter()).cloned().collect::>().into() } 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, /// but if the reaction system is consistent there wont be any problem. fn union(&self, other: &Self) -> Self { - let mut ret: Self = other.clone(); - ret.identifiers.extend(self.identifiers.iter()); - ret + self.iter().chain(other.iter()).map(|(a, b)| (*a, *b)) + .collect::>().into() } fn push(&mut self, other: &Self) {