Skip to content

Commit

Permalink
Remove 1 loop on rowDescription event (#3056)
Browse files Browse the repository at this point in the history
* Remove 1 loop on rowDescription event

* Update packages/pg/lib/result.js

Co-authored-by: Charmander <~@charmander.me>

---------

Co-authored-by: Charmander <~@charmander.me>
  • Loading branch information
brianc and charmander authored Sep 15, 2023
1 parent 106ca8a commit da0f5c5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/pg/lib/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Result {
}

parseRow(rowData) {
var row = { ... this._prebuiltEmptyResultObject }
var row = { ...this._prebuiltEmptyResultObject }
for (var i = 0, len = rowData.length; i < len; i++) {
var rawValue = rowData[i]
var field = this.fields[i].name
Expand All @@ -87,22 +87,20 @@ class Result {
if (this.fields.length) {
this._parsers = new Array(fieldDescriptions.length)
}

var row = {}

for (var i = 0; i < fieldDescriptions.length; i++) {
var desc = fieldDescriptions[i]
row[desc.name] = null

if (this._types) {
this._parsers[i] = this._types.getTypeParser(desc.dataTypeID, desc.format || 'text')
} else {
this._parsers[i] = types.getTypeParser(desc.dataTypeID, desc.format || 'text')
}
}
this._createPrebuiltEmptyResultObject()
}
_createPrebuiltEmptyResultObject() {
var row = {}
for (var i = 0; i < this.fields.length; i++) {
row[this.fields[i].name] = null
}
this._prebuiltEmptyResultObject = { ... row }
this._prebuiltEmptyResultObject = { ...row }
}
}

Expand Down

0 comments on commit da0f5c5

Please sign in to comment.