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
|
||||
|
||||
* 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
|
||||
|
||||
* 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) {
|
||||
var Int32Len = 4;
|
||||
this.push(copyDataBuffer)
|
||||
var lenBuffer = Buffer.alloc(Int32Len)
|
||||
lenBuffer.writeUInt32BE(chunk.length + Int32Len, 0)
|
||||
var lenBuffer = Buffer.from([code.CopyData, 0, 0, 0, 0])
|
||||
lenBuffer.writeUInt32BE(chunk.length + Int32Len, 1)
|
||||
this.push(lenBuffer)
|
||||
this.push(chunk)
|
||||
cb()
|
||||
|
Loading…
Reference in New Issue
Block a user