perf: remove one call to push in copy-from transform loop

This commit is contained in:
jeromew 2019-03-20 09:21:28 +00:00
parent 98d8d8a8e0
commit cffae659b8
2 changed files with 4 additions and 4 deletions

View File

@ -87,6 +87,8 @@ Since this isn't a module with tons of installs and dependent modules I hope we
### version 2.x - published YYYY-MM-DD ### version 2.x - published YYYY-MM-DD
* Small refactor in copy-from passing from 3 push to 2 push in every chunk transform loop
### version 2.1.0 - published 2019-03-19 ### version 2.1.0 - published 2019-03-19
* Change README to stop using the pg pool singleton (removed after pg 7.0) * Change README to stop using the pg pool singleton (removed after pg 7.0)

View File

@ -30,12 +30,10 @@ CopyStreamQuery.prototype.submit = function(connection) {
} }
var copyDataBuffer = Buffer.from([code.CopyData])
CopyStreamQuery.prototype._transform = function(chunk, enc, cb) { CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
var Int32Len = 4; var Int32Len = 4;
this.push(copyDataBuffer) var lenBuffer = Buffer.from([code.CopyData, 0, 0, 0, 0])
var lenBuffer = Buffer.alloc(Int32Len) lenBuffer.writeUInt32BE(chunk.length + Int32Len, 1)
lenBuffer.writeUInt32BE(chunk.length + Int32Len, 0)
this.push(lenBuffer) this.push(lenBuffer)
this.push(chunk) this.push(chunk)
cb() cb()