@@ -426,18 +426,19 @@ namespace ts {
426
426
let processingSingleLineComment = false ;
427
427
let processingMultiLineComment = false ;
428
428
for ( let i = 0 ; i < jsonText . length ; i ++ ) {
429
+ let currentCharCode = jsonText . charCodeAt ( i ) ;
429
430
let currentChar = jsonText . charAt ( i ) ;
430
- let nextChar = ( i + 1 < jsonText . length ) ? jsonText . charAt ( i + 1 ) : undefined ;
431
+ let nextCharCode = ( i + 1 < jsonText . length ) ? jsonText . charCodeAt ( i + 1 ) : undefined ;
431
432
if ( processingString ) {
432
- if ( currentChar === "\\"
433
- && nextChar !== undefined ) {
433
+ if ( currentCharCode === CharacterCodes . backslash
434
+ && nextCharCode !== undefined ) {
434
435
// Found an escaped character
435
436
// consume the \ and the escaped char
436
437
result += currentChar ;
437
- result += nextChar ;
438
+ result += jsonText . charAt ( i + 1 ) ;
438
439
i += 1 ;
439
440
}
440
- else if ( currentChar === "\"" ) {
441
+ else if ( currentCharCode === CharacterCodes . doubleQuote ) {
441
442
// End of string
442
443
result += currentChar ;
443
444
processingString = false ;
@@ -448,7 +449,7 @@ namespace ts {
448
449
}
449
450
}
450
451
else if ( processingSingleLineComment ) {
451
- if ( currentChar === "\n" ) {
452
+ if ( isLineBreak ( currentCharCode ) ) {
452
453
// End of single line comment
453
454
processingSingleLineComment = false ;
454
455
// Keep the line breaks to keep line numbers aligned
@@ -460,13 +461,13 @@ namespace ts {
460
461
}
461
462
}
462
463
else if ( processingMultiLineComment ) {
463
- if ( currentChar === "*" && nextChar === "/" ) {
464
- // End of comment
464
+ if ( currentCharCode === CharacterCodes . asterisk && nextCharCode === CharacterCodes . slash ) {
465
+ // End of comment */
465
466
result += " " ;
466
467
i += 1 ;
467
468
processingMultiLineComment = false ;
468
469
}
469
- else if ( currentChar === "\n" ) {
470
+ else if ( isLineBreak ( currentCharCode ) ) {
470
471
// Keep the line breaks to Keep line aligned
471
472
result += currentChar ;
472
473
}
@@ -475,23 +476,23 @@ namespace ts {
475
476
result += " " ;
476
477
}
477
478
}
478
- else if ( currentChar === "\"" ) {
479
+ else if ( currentCharCode === CharacterCodes . doubleQuote ) {
479
480
// String start
480
481
result += currentChar ;
481
482
processingString = true ;
482
483
}
483
- else if ( currentChar === "#" ) {
484
+ else if ( currentCharCode === CharacterCodes . hash ) {
484
485
// Start of # comment
485
486
result += " " ;
486
487
processingSingleLineComment = true ;
487
488
}
488
- else if ( currentChar === "/" && nextChar === "/" ) {
489
+ else if ( currentCharCode === CharacterCodes . slash && nextCharCode === CharacterCodes . slash ) {
489
490
// Start of // comment
490
491
result += " " ;
491
492
i += 1 ;
492
493
processingSingleLineComment = true ;
493
494
}
494
- else if ( currentChar === "/" && nextChar === "*" ) {
495
+ else if ( currentCharCode === CharacterCodes . slash && nextCharCode === CharacterCodes . asterisk ) {
495
496
// Start of /**/ comment
496
497
result += " " ;
497
498
i += 1 ;
0 commit comments