perf: remove one call to push in copy-from transform loop
This commit is contained in:
parent
98d8d8a8e0
commit
cffae659b8
@ -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)
|
||||||
|
6
index.js
6
index.js
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user