@@ -18,46 +18,43 @@ class Result {
18
18
19
19
consumeFields ( pq ) {
20
20
const nfields = pq . nfields ( )
21
+ this . fields = new Array ( nfields )
21
22
for ( var x = 0 ; x < nfields ; x ++ ) {
22
- this . fields . push ( {
23
+ this . fields [ x ] = {
23
24
name : pq . fname ( x ) ,
24
25
dataTypeID : pq . ftype ( x ) ,
25
- } )
26
+ }
26
27
}
27
28
}
28
29
29
30
consumeRows ( pq ) {
30
31
const tupleCount = pq . ntuples ( )
32
+ this . rows = new Array ( tupleCount )
31
33
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 )
34
35
}
35
36
}
36
37
37
38
consumeRowAsObject ( pq , rowIndex ) {
38
39
const row = { }
39
40
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 )
42
42
}
43
43
return row
44
44
}
45
45
46
46
consumeRowAsArray ( pq , rowIndex ) {
47
- const row = [ ]
47
+ const row = new Array ( this . fields . length )
48
48
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 )
51
50
}
52
51
return row
53
52
}
54
53
55
54
readValue ( pq , rowIndex , colIndex ) {
56
55
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
61
58
}
62
59
const dataTypeId = this . fields [ colIndex ] . dataTypeID
63
60
return this . _types . getTypeParser ( dataTypeId ) ( rawValue )
0 commit comments