File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -435,23 +435,21 @@ namespace ts {
435435 export function sameMap < T > ( array : T [ ] , f : ( x : T , i : number ) => T ) : T [ ] ;
436436 export function sameMap < T > ( array : ReadonlyArray < T > , f : ( x : T , i : number ) => T ) : ReadonlyArray < T > ;
437437 export function sameMap < T > ( array : T [ ] , f : ( x : T , i : number ) => T ) : T [ ] {
438- let result : T [ ] ;
439438 if ( array ) {
440439 for ( let i = 0 ; i < array . length ; i ++ ) {
441- if ( result ) {
442- result . push ( f ( array [ i ] , i ) ) ;
443- }
444- else {
445- const item = array [ i ] ;
446- const mapped = f ( item , i ) ;
447- if ( item !== mapped ) {
448- result = array . slice ( 0 , i ) ;
449- result . push ( mapped ) ;
440+ const item = array [ i ] ;
441+ const mapped = f ( item , i ) ;
442+ if ( item !== mapped ) {
443+ const result = array . slice ( 0 , i ) ;
444+ result . push ( mapped ) ;
445+ for ( i ++ ; i < array . length ; i ++ ) {
446+ result . push ( f ( array [ i ] , i ) ) ;
450447 }
448+ return result ;
451449 }
452450 }
453451 }
454- return result || array ;
452+ return array ;
455453 }
456454
457455 /**
You can’t perform that action at this time.
0 commit comments