Created
December 22, 2023 06:05
-
-
Save asd142513/2409db24028a9db50391e1ce9f49b855 to your computer and use it in GitHub Desktop.
black box
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl State { | |
fn new(valves: &[Valve]) -> Self { | |
// let valve_states = black_box(valves) | |
// .iter() | |
// .map(|valve| valve.rate == 0) | |
// .collect(); | |
let mut valve_states = Vec::with_capacity(black_box(valves).len()); // Fast | |
for valve in valves { | |
valve_states.push(black_box(valve).rate == 0); | |
} | |
let valve_states = black_box(valve_states); | |
State { | |
valve_states, | |
position: 0, | |
rate: 0, | |
released_pressure: 0, | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment