File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,12 +51,16 @@ var TAB = "\t".charCodeAt(0);
5151
5252var STRING_BUFFER_SIZE = 64 * 1024 ;
5353
54+ function alloc ( size ) {
55+ return Buffer . alloc ? Buffer . alloc ( size ) : new Buffer ( size ) ;
56+ }
57+
5458function Parser ( ) {
5559 this . tState = START ;
5660 this . value = undefined ;
5761
5862 this . string = undefined ; // string data
59- this . stringBuffer = Buffer . alloc ? Buffer . alloc ( STRING_BUFFER_SIZE ) : new Buffer ( STRING_BUFFER_SIZE ) ;
63+ this . stringBuffer = alloc ( STRING_BUFFER_SIZE ) ;
6064 this . stringBufferOffset = 0 ;
6165 this . unicode = undefined ; // unicode escapes
6266 this . highSurrogate = undefined ;
@@ -67,7 +71,7 @@ function Parser() {
6771 this . state = VALUE ;
6872 this . bytes_remaining = 0 ; // number of bytes remaining in multi byte utf8 char to read after split boundary
6973 this . bytes_in_sequence = 0 ; // bytes in multi byte utf8 char to read
70- this . temp_buffs = { "2" : new Buffer ( 2 ) , "3" : new Buffer ( 3 ) , "4" : new Buffer ( 4 ) } ; // for rebuilding chars split before boundary is reached
74+ this . temp_buffs = { "2" : alloc ( 2 ) , "3" : alloc ( 3 ) , "4" : alloc ( 4 ) } ; // for rebuilding chars split before boundary is reached
7175
7276 // Stream offset
7377 this . offset = - 1 ;
You can’t perform that action at this time.
0 commit comments