@@ -524,19 +524,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
524
524
/// avoid allocations.
525
525
pub fn eval_place_to_op (
526
526
& self ,
527
- place : mir:: Place < ' tcx > ,
527
+ mir_place : mir:: Place < ' tcx > ,
528
528
layout : Option < TyAndLayout < ' tcx > > ,
529
529
) -> InterpResult < ' tcx , OpTy < ' tcx , M :: PointerTag > > {
530
530
// Do not use the layout passed in as argument if the base we are looking at
531
531
// here is not the entire place.
532
- let layout = if place . projection . is_empty ( ) { layout } else { None } ;
532
+ let layout = if mir_place . projection . is_empty ( ) { layout } else { None } ;
533
533
534
- let base_op = self . local_to_op ( self . frame ( ) , place. local , layout) ?;
535
-
536
- let op = place
537
- . projection
538
- . iter ( )
539
- . try_fold ( base_op, |op, elem| self . operand_projection ( & op, elem) ) ?;
534
+ let mut op = self . local_to_op ( self . frame ( ) , mir_place. local , layout) ?;
535
+ // Using `try_fold` turned out to be bad for performance, hence the loop.
536
+ for elem in mir_place. projection . iter ( ) {
537
+ op = self . operand_projection ( & op, elem) ?
538
+ }
540
539
541
540
trace ! ( "eval_place_to_op: got {:?}" , * op) ;
542
541
// Sanity-check the type we ended up with.
@@ -545,12 +544,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
545
544
* self . tcx,
546
545
self . param_env,
547
546
self . layout_of( self . subst_from_current_frame_and_normalize_erasing_regions(
548
- place . ty( & self . frame( ) . body. local_decls, * self . tcx) . ty
547
+ mir_place . ty( & self . frame( ) . body. local_decls, * self . tcx) . ty
549
548
) ?) ?,
550
549
op. layout,
551
550
) ,
552
551
"eval_place of a MIR place with type {:?} produced an interpreter operand with type {:?}" ,
553
- place . ty( & self . frame( ) . body. local_decls, * self . tcx) . ty,
552
+ mir_place . ty( & self . frame( ) . body. local_decls, * self . tcx) . ty,
554
553
op. layout. ty,
555
554
) ;
556
555
Ok ( op)
0 commit comments