File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -447,22 +447,23 @@ namespace ts {
447447
448448 //// Path Normalization
449449
450+ const normalizeSlashesSegmentBuffer : string [ ] = [ ] ;
450451 /**
451452 * Normalize path separators, converting `\` into `/`.
452453 */
453454 export function normalizeSlashes ( path : string ) : string {
455+ normalizeSlashesSegmentBuffer . length = 0 ;
454456 let lastSliceStart = 0 ;
455- let segments : string [ ] | undefined ;
456457 for ( let i = 0 ; i < path . length ; i ++ ) {
457458 const c = path . charCodeAt ( i ) ;
458459 if ( c === CharacterCodes . backslash ) {
459- ( segments ||= [ ] ) . push ( path . slice ( lastSliceStart , i ) ) ;
460+ normalizeSlashesSegmentBuffer . push ( path . slice ( lastSliceStart , i ) ) ;
460461 lastSliceStart = i + 1 ;
461462 }
462463 }
463- if ( segments ) {
464- segments . push ( path . slice ( lastSliceStart ) ) ;
465- return segments . join ( directorySeparator ) ;
464+ if ( normalizeSlashesSegmentBuffer . length > 0 ) {
465+ normalizeSlashesSegmentBuffer . push ( path . slice ( lastSliceStart ) ) ;
466+ return normalizeSlashesSegmentBuffer . join ( directorySeparator ) ;
466467 }
467468 return path ;
468469 }
You can’t perform that action at this time.
0 commit comments