fn compute(input: &u32, output: &mut u32) {
    // keep *input in a register
    let cached_input = *input;
    if cached_input > 10 {
        // x > 10 implies x > 5, so double and exit immediately
        *output = 2;
    } else if cached_input > 5 {
        *output *= 2;
    }
}
//* Example 1: Optimized way is to keep input in a register.
Example 1: Optimized way is to keep input in a register.
Example 1 : Optimized way is to keep input in a register .
fn compute(input: &u32, output: &mut u32) {
    // keep *input in a register
    let cached_input = *input;
    if cached_input > 10 {
        // x > 10 implies x > 5, so double and exit immediately
        *output = 2;
    } else if cached_input > 5 {
        *output *= 2;
    }
}
fn compute ( input : & u32 , output : & mut u32 ) { // keep *input in a register let cached_input = * input ; if cached_input > 10 { // x > 10 implies x > 5, so double and exit immediately * output = 2 ; } else if cached_input > 5 { * output *= 2 ; } }
Example 1: Optimized way is to keep input in a register.
Example 1 : Optimized way is to keep input in a register .
input
&u32
output
&mut u32