New issue

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

Optimize unreachable branches #5

Closed
zslayton opened this Issue May 28, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@zslayton
Owner

zslayton commented May 28, 2015

Use something like this crate to help the compiler optimize away bits like:

   fn as_ref(&self) -> &T {
    match self.value.as_ref() {
      Some(v) => v,
      // This is unreachable but is currently preserved by LLVM
      None => panic!("Recycled<T> smartpointer missing its value.")
    }
  }
@zslayton

This comment has been minimized.

Owner

zslayton commented Jun 1, 2015

At present, it is possible for the Recycled and RcRecycled types to be missing their wrapped value by the time they reach the destructor because of the detach method, which unwraps it. Because of that, it is only possible to add this optimization in the as_ref and as_mut methods. Investigating whether this can be revised.

@zslayton zslayton closed this in c133e7e Nov 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment