We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a94fe9 commit fc5ca64Copy full SHA for fc5ca64
packages/pg-protocol/src/buffer-writer.ts
@@ -1,10 +1,12 @@
1
//binary data writer tuned for encoding binary specific to the postgres binary protocol
2
3
+const MaxSize = 8192 //8kb
4
+
5
export class Writer {
6
private buffer: Buffer
7
private offset: number = 5
8
private headerPosition: number = 0
- constructor(private size = 256) {
9
+ constructor(private size = 512) {
10
this.buffer = Buffer.allocUnsafeSlow(size)
11
}
12
@@ -91,7 +93,9 @@ export class Writer {
91
93
let result = this.join(code)
92
94
this.offset = 5
95
this.headerPosition = 0
- this.buffer = Buffer.allocUnsafeSlow(this.size)
96
+ if(this.buffer.length > MaxSize) {
97
+ this.buffer = Buffer.allocUnsafeSlow(this.size)
98
+ }
99
return result
100
101
0 commit comments