@@ -1376,55 +1376,6 @@ impl<'tcx> BasicBlockData<'tcx> {
13761376 }
13771377 }
13781378
1379- pub fn expand_statements < F , I > ( & mut self , mut f : F )
1380- where
1381- F : FnMut ( & mut Statement < ' tcx > ) -> Option < I > ,
1382- I : iter:: TrustedLen < Item = Statement < ' tcx > > ,
1383- {
1384- // Gather all the iterators we'll need to splice in, and their positions.
1385- let mut splices: Vec < ( usize , I ) > = vec ! [ ] ;
1386- let mut extra_stmts = 0 ;
1387- for ( i, s) in self . statements . iter_mut ( ) . enumerate ( ) {
1388- if let Some ( mut new_stmts) = f ( s) {
1389- if let Some ( first) = new_stmts. next ( ) {
1390- // We can already store the first new statement.
1391- * s = first;
1392-
1393- // Save the other statements for optimized splicing.
1394- let remaining = new_stmts. size_hint ( ) . 0 ;
1395- if remaining > 0 {
1396- splices. push ( ( i + 1 + extra_stmts, new_stmts) ) ;
1397- extra_stmts += remaining;
1398- }
1399- } else {
1400- s. make_nop ( ) ;
1401- }
1402- }
1403- }
1404-
1405- // Splice in the new statements, from the end of the block.
1406- // FIXME(eddyb) This could be more efficient with a "gap buffer"
1407- // where a range of elements ("gap") is left uninitialized, with
1408- // splicing adding new elements to the end of that gap and moving
1409- // existing elements from before the gap to the end of the gap.
1410- // For now, this is safe code, emulating a gap but initializing it.
1411- let mut gap = self . statements . len ( ) ..self . statements . len ( ) + extra_stmts;
1412- self . statements . resize (
1413- gap. end ,
1414- Statement { source_info : SourceInfo :: outermost ( DUMMY_SP ) , kind : StatementKind :: Nop } ,
1415- ) ;
1416- for ( splice_start, new_stmts) in splices. into_iter ( ) . rev ( ) {
1417- let splice_end = splice_start + new_stmts. size_hint ( ) . 0 ;
1418- while gap. end > splice_end {
1419- gap. start -= 1 ;
1420- gap. end -= 1 ;
1421- self . statements . swap ( gap. start , gap. end ) ;
1422- }
1423- self . statements . splice ( splice_start..splice_end, new_stmts) ;
1424- gap. end = splice_start;
1425- }
1426- }
1427-
14281379 pub fn visitable ( & self , index : usize ) -> & dyn MirVisitable < ' tcx > {
14291380 if index < self . statements . len ( ) { & self . statements [ index] } else { & self . terminator }
14301381 }
0 commit comments