We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why Aliasing Matters
In chapter 3.2(Aliasing), Why Aliasing Matters section, is the optimize example wrong?
fn compute(input: &u32, output: &mut u32) { let cached_input = *input; // keep *input in a register if cached_input > 10 { *output = 2; // x > 10 implies x > 5, so double and exit immediately } else if cached_input > 5 { *output *= 2; } }
should be:
fn compute(input: &u32, output: &mut u32) { let cached_input = *input; // keep *input in a register if cached_input > 10 { *output *= 2; // x > 10 implies x > 5, so double and exit immediately } else if cached_input > 5 { *output *= 2; } }
or
fn compute(input: &u32, output: &mut u32) { let cached_input = *input; // keep *input in a register if cached_input > 10 { *output = 1; // x > 10 implies x > 5, so double and exit immediately } else if cached_input > 5 { *output *= 2; } }
The text was updated successfully, but these errors were encountered:
No it's correct. When it's > 10 we set it to 1 and then double it. The given optimization is to just replace this with setting it to 2.
> 10
It's a misleading comment, though. That should be fixed.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
In chapter 3.2(Aliasing),
Why Aliasing Matters
section, is the optimize example wrong?should be:
or
The text was updated successfully, but these errors were encountered: