@@ -18,46 +18,43 @@ class Result {
1818
1919 consumeFields ( pq ) {
2020 const nfields = pq . nfields ( )
21+ this . fields = new Array ( nfields )
2122 for ( var x = 0 ; x < nfields ; x ++ ) {
22- this . fields . push ( {
23+ this . fields [ x ] = {
2324 name : pq . fname ( x ) ,
2425 dataTypeID : pq . ftype ( x ) ,
25- } )
26+ }
2627 }
2728 }
2829
2930 consumeRows ( pq ) {
3031 const tupleCount = pq . ntuples ( )
32+ this . rows = new Array ( tupleCount )
3133 for ( var i = 0 ; i < tupleCount ; i ++ ) {
32- const row = this . _arrayMode ? this . consumeRowAsArray ( pq , i ) : this . consumeRowAsObject ( pq , i )
33- this . rows . push ( row )
34+ this . rows [ i ] = this . _arrayMode ? this . consumeRowAsArray ( pq , i ) : this . consumeRowAsObject ( pq , i )
3435 }
3536 }
3637
3738 consumeRowAsObject ( pq , rowIndex ) {
3839 const row = { }
3940 for ( var j = 0 ; j < this . fields . length ; j ++ ) {
40- const value = this . readValue ( pq , rowIndex , j )
41- row [ this . fields [ j ] . name ] = value
41+ row [ this . fields [ j ] . name ] = this . readValue ( pq , rowIndex , j )
4242 }
4343 return row
4444 }
4545
4646 consumeRowAsArray ( pq , rowIndex ) {
47- const row = [ ]
47+ const row = new Array ( this . fields . length )
4848 for ( var j = 0 ; j < this . fields . length ; j ++ ) {
49- const value = this . readValue ( pq , rowIndex , j )
50- row . push ( value )
49+ row [ j ] = this . readValue ( pq , rowIndex , j )
5150 }
5251 return row
5352 }
5453
5554 readValue ( pq , rowIndex , colIndex ) {
5655 var rawValue = pq . getvalue ( rowIndex , colIndex )
57- if ( rawValue === '' ) {
58- if ( pq . getisnull ( rowIndex , colIndex ) ) {
59- return null
60- }
56+ if ( rawValue === '' && pq . getisnull ( rowIndex , colIndex ) ) {
57+ return null
6158 }
6259 const dataTypeId = this . fields [ colIndex ] . dataTypeID
6360 return this . _types . getTypeParser ( dataTypeId ) ( rawValue )
0 commit comments