performance optimization in 54

This commit is contained in:
Dr. Matthias Ratajczak
2022-08-18 18:11:12 +02:00
parent 06f722ba7f
commit dd8ea500ae
3 changed files with 3 additions and 7 deletions
-1
View File
@@ -11,7 +11,6 @@ num = "*"
[dev-dependencies] [dev-dependencies]
criterion = "*" criterion = "*"
[[bench]] [[bench]]
name = "benchmark" name = "benchmark"
harness = false harness = false
+2 -2
View File
@@ -11,8 +11,6 @@ path = "src/lib.rs"
name = "euler54" name = "euler54"
path = "src/main.rs" path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
rstest = "*" rstest = "*"
@@ -21,6 +19,8 @@ criterion = "*"
[profile.release] [profile.release]
debug = true debug = true
lto = true
codegen-units = 1
[[bench]] [[bench]]
name = "benchmark" name = "benchmark"
+1 -4
View File
@@ -51,10 +51,7 @@ impl Cards {
} }
pub fn have_matching_suits(&self) -> bool { pub fn have_matching_suits(&self) -> bool {
self.array[1..] self.suit_hashset.len() == 1
.iter()
.zip(self.array[..4].iter())
.all(|(c1, c2)| c1.suit == c2.suit)
} }
pub fn contain_all_values_of(&self, values: &Values) -> bool { pub fn contain_all_values_of(&self, values: &Values) -> bool {