File tree Expand file tree Collapse file tree 1 file changed +43
-10
lines changed Expand file tree Collapse file tree 1 file changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -3964,13 +3964,29 @@ namespace ts {
3964
3964
3965
3965
function appendRawSmall ( text : string ) {
3966
3966
const len = text . length ;
3967
- for ( let pos = 0 ; pos < len ; pos ++ ) {
3967
+ let pos = 0 ;
3968
+ while ( pos < len ) {
3968
3969
const ch = text . charCodeAt ( pos ) ;
3969
3970
appendCharCode ( ch ) ;
3970
- // Ignore carriageReturn, since we mark the following lineFeed as the newline anyway
3971
- if ( isLineBreak ( ch ) && ch !== CharacterCodes . carriageReturn ) {
3972
- ++ lineCount ;
3973
- linePos = totalChars ;
3971
+ pos ++ ;
3972
+ switch ( ch ) {
3973
+ case CharacterCodes . carriageReturn :
3974
+ const nextChar = text . charCodeAt ( pos ) ;
3975
+ if ( nextChar === CharacterCodes . lineFeed ) {
3976
+ appendCharCode ( nextChar ) ;
3977
+ pos ++ ;
3978
+ }
3979
+ // falls through
3980
+ case CharacterCodes . lineFeed :
3981
+ ++ lineCount ;
3982
+ linePos = totalChars ;
3983
+ break ;
3984
+ default :
3985
+ if ( ch > CharacterCodes . maxAsciiCharacter && isLineBreak ( ch ) ) {
3986
+ ++ lineCount ;
3987
+ linePos = totalChars ;
3988
+ }
3989
+ break ;
3974
3990
}
3975
3991
}
3976
3992
@@ -3981,14 +3997,31 @@ namespace ts {
3981
3997
flushBuffer ( ) ;
3982
3998
3983
3999
const len = text . length ;
3984
- for ( let pos = 0 ; pos < len ; pos ++ ) {
4000
+ let pos = 0 ;
4001
+ while ( pos < len ) {
3985
4002
const ch = text . charCodeAt ( pos ) ;
3986
4003
++ totalChars ;
3987
4004
lastChar = ch ;
3988
- // Ignore carriageReturn, since we mark the following lineFeed as the newline anyway
3989
- if ( isLineBreak ( ch ) && ch !== CharacterCodes . carriageReturn ) {
3990
- ++ lineCount ;
3991
- linePos = totalChars ;
4005
+ pos ++ ;
4006
+ switch ( ch ) {
4007
+ case CharacterCodes . carriageReturn :
4008
+ const nextChar = text . charCodeAt ( pos ) ;
4009
+ if ( nextChar === CharacterCodes . lineFeed ) {
4010
+ ++ totalChars ;
4011
+ lastChar = nextChar ;
4012
+ pos ++ ;
4013
+ }
4014
+ // falls through
4015
+ case CharacterCodes . lineFeed :
4016
+ ++ lineCount ;
4017
+ linePos = totalChars ;
4018
+ break ;
4019
+ default :
4020
+ if ( ch > CharacterCodes . maxAsciiCharacter && isLineBreak ( ch ) ) {
4021
+ ++ lineCount ;
4022
+ linePos = totalChars ;
4023
+ }
4024
+ break ;
3992
4025
}
3993
4026
}
3994
4027
You can’t perform that action at this time.
0 commit comments