@@ -40,6 +40,14 @@ var KEY = C.KEY = 0x72;
4040// Parser Modes
4141var OBJECT = C . OBJECT = 0x81 ;
4242var ARRAY = C . ARRAY = 0x82 ;
43+ // Character constants
44+ var BACK_SLASH = "\\" . charCodeAt ( 0 ) ;
45+ var FORWARD_SLASH = "\/" . charCodeAt ( 0 ) ;
46+ var BACKSPACE = "\b" . charCodeAt ( 0 ) ;
47+ var FORM_FEED = "\f" . charCodeAt ( 0 ) ;
48+ var NEWLINE = "\n" . charCodeAt ( 0 ) ;
49+ var CARRIAGE_RETURN = "\r" . charCodeAt ( 0 ) ;
50+ var TAB = "\t" . charCodeAt ( 0 ) ;
4351
4452var STRING_BUFFER_SIZE = 64 * 1024 ;
4553
@@ -184,13 +192,13 @@ proto.write = function (buffer) {
184192 } else if ( this . tState === STRING2 ) { // After backslash
185193 n = buffer [ i ] ;
186194 if ( n === 0x22 ) { this . appendStringChar ( n ) ; this . tState = STRING1 ;
187- } else if ( n === 0x5c ) { this . appendStringChar ( "\\" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
188- } else if ( n === 0x2f ) { this . appendStringChar ( "\/" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
189- } else if ( n === 0x62 ) { this . appendStringChar ( "\b" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
190- } else if ( n === 0x66 ) { this . appendStringChar ( "\f" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
191- } else if ( n === 0x6e ) { this . appendStringChar ( "\n" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
192- } else if ( n === 0x72 ) { this . appendStringChar ( "\r" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
193- } else if ( n === 0x74 ) { this . appendStringChar ( "\t" . charCodeAt ( 0 ) ) ; this . tState = STRING1 ;
195+ } else if ( n === 0x5c ) { this . appendStringChar ( BACK_SLASH ) ; this . tState = STRING1 ;
196+ } else if ( n === 0x2f ) { this . appendStringChar ( FORWARD_SLASH ) ; this . tState = STRING1 ;
197+ } else if ( n === 0x62 ) { this . appendStringChar ( BACKSPACE ) ; this . tState = STRING1 ;
198+ } else if ( n === 0x66 ) { this . appendStringChar ( FORM_FEED ) ; this . tState = STRING1 ;
199+ } else if ( n === 0x6e ) { this . appendStringChar ( NEWLINE ) ; this . tState = STRING1 ;
200+ } else if ( n === 0x72 ) { this . appendStringChar ( CARRIAGE_RETURN ) ; this . tState = STRING1 ;
201+ } else if ( n === 0x74 ) { this . appendStringChar ( TAB ) ; this . tState = STRING1 ;
194202 } else if ( n === 0x75 ) { this . unicode = "" ; this . tState = STRING3 ;
195203 } else {
196204 return this . charError ( buffer , i ) ;
0 commit comments