@@ -524,19 +524,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
524524     /// avoid allocations. 
525525     pub  fn  eval_place_to_op ( 
526526        & self , 
527-         place :  mir:: Place < ' tcx > , 
527+         mir_place :  mir:: Place < ' tcx > , 
528528        layout :  Option < TyAndLayout < ' tcx > > , 
529529    )  -> InterpResult < ' tcx ,  OpTy < ' tcx ,  M :: PointerTag > >  { 
530530        // Do not use the layout passed in as argument if the base we are looking at 
531531        // 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  } ; 
533533
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+         } 
540539
541540        trace ! ( "eval_place_to_op: got {:?}" ,  * op) ; 
542541        // Sanity-check the type we ended up with. 
@@ -545,12 +544,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
545544                * self . tcx, 
546545                self . param_env, 
547546                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
549548                ) ?) ?, 
550549                op. layout, 
551550            ) , 
552551            "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, 
554553            op. layout. ty, 
555554        ) ; 
556555        Ok ( op) 
0 commit comments