summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Mora Unie Youer <[email protected]>2025-04-28 10:21:50 +0300
committerLibravatar Mora Unie Youer <[email protected]>2025-04-28 10:21:50 +0300
commit328c73a9b176e449f0a5d4f35715865710eaa3c9 (patch)
tree5c07d0e25e3c829fc266ac5304d7ac6265d89e3e /src/main.rs
parentfix: incorrect CNF result when no variables are used (diff)
downloadlogic-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/main.rs')
-rw-r--r--src/main.rs5
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 = &current_cubes[i];
+
for j in i + 1..current_cubes.len() {
- let a = &current_cubes[i];
let b = &current_cubes[j];
if let Some(combined_cube) = a.combine(b) {