Skip to content
Permalink
Browse files

Remove an intermediate value from discriminant reading

  • Loading branch information...
oli-obk committed Feb 16, 2019
1 parent 235a6b7 commit bd18cc5708328600a94a02444caf27a5fb6ca20c
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/librustc_mir/interpret/operand.rs
  2. +2 −2 src/librustc_mir/interpret/step.rs
@@ -508,7 +508,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>

// Evaluate a place with the goal of reading from it. This lets us sometimes
// avoid allocations.
fn eval_place_to_op(
pub(super) fn eval_place_to_op(
&self,
mir_place: &mir::Place<'tcx>,
layout: Option<TyLayout<'tcx>>,
@@ -266,8 +266,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
}

Discriminant(ref place) => {
let place = self.eval_place(place)?;
let discr_val = self.read_discriminant(self.place_to_op(place)?)?.0;
let op = self.eval_place_to_op(place, None)?;
let discr_val = self.read_discriminant(op)?.0;
let size = dest.layout.size;
self.write_scalar(Scalar::from_uint(discr_val, size), dest)?;
}

0 comments on commit bd18cc5

Please sign in to comment.
You can’t perform that action at this time.