File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -447,22 +447,23 @@ namespace ts {
447
447
448
448
//// Path Normalization
449
449
450
+ const normalizeSlashesSegmentBuffer : string [ ] = [ ] ;
450
451
/**
451
452
* Normalize path separators, converting `\` into `/`.
452
453
*/
453
454
export function normalizeSlashes ( path : string ) : string {
455
+ normalizeSlashesSegmentBuffer . length = 0 ;
454
456
let lastSliceStart = 0 ;
455
- let segments : string [ ] | undefined ;
456
457
for ( let i = 0 ; i < path . length ; i ++ ) {
457
458
const c = path . charCodeAt ( i ) ;
458
459
if ( c === CharacterCodes . backslash ) {
459
- ( segments ||= [ ] ) . push ( path . slice ( lastSliceStart , i ) ) ;
460
+ normalizeSlashesSegmentBuffer . push ( path . slice ( lastSliceStart , i ) ) ;
460
461
lastSliceStart = i + 1 ;
461
462
}
462
463
}
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 ) ;
466
467
}
467
468
return path ;
468
469
}
You can’t perform that action at this time.
0 commit comments