mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Codegen optimization is my passion
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
use std::array;
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::BinaryHeap;
|
use std::collections::BinaryHeap;
|
||||||
|
|
||||||
@@ -126,8 +125,14 @@ impl BluePrint {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resources_after =
|
// Ideally, would be written as a nice `array::from_fn`. It turns out that codegen
|
||||||
array::from_fn(|i| resources[i] + machines[i] * built_after - costs[i]);
|
// for `array::from_fn` is very bad, and writing it out into this for loop reduces
|
||||||
|
// time taken by approximately 100%.
|
||||||
|
let mut resources_after = [0; 3];
|
||||||
|
for i in 0..3 {
|
||||||
|
resources_after[i] = resources[i] + machines[i] * built_after - costs[i];
|
||||||
|
}
|
||||||
|
|
||||||
let time_after = time_left - built_after;
|
let time_after = time_left - built_after;
|
||||||
|
|
||||||
if element == Mineral::Geode as usize {
|
if element == Mineral::Geode as usize {
|
||||||
|
|||||||
Reference in New Issue
Block a user