diff options
author | 2025-04-28 10:21:50 +0300 | |
---|---|---|
committer | 2025-04-28 10:21:50 +0300 | |
commit | 328c73a9b176e449f0a5d4f35715865710eaa3c9 (patch) | |
tree | 5c07d0e25e3c829fc266ac5304d7ac6265d89e3e /src | |
parent | fix: incorrect CNF result when no variables are used (diff) | |
download | logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.tar.gz logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.tar.bz2 logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.tar.lz logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.tar.xz logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.tar.zst logic-rust-328c73a9b176e449f0a5d4f35715865710eaa3c9.zip |
perf: minimization algorithm now a little faster
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e8c3849..75c796a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,8 @@ impl Cube { let dt = self.t ^ other.t; let df = self.f ^ other.f; + // NOTE: this should be compiled with all optimizations possible + // as `.count_ones()` is bottleneck if dt == df && dt.count_ones() == 1 { Some(Self { t: self.t & other.t, @@ -64,8 +66,9 @@ fn minimize_prime_implicants(n: usize, minterms: &[usize], maxterms: &[usize]) - let mut new_cubes = HashSet::new(); for i in 0..current_cubes.len() { + let a = ¤t_cubes[i]; + for j in i + 1..current_cubes.len() { - let a = ¤t_cubes[i]; let b = ¤t_cubes[j]; if let Some(combined_cube) = a.combine(b) { |