Skip to content

Commit 35c1f4a

Browse files
committed
perf(csv-parse): buffer unsafe allocation
1 parent 469fb38 commit 35c1f4a

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

packages/csv-parse/dist/cjs/index.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4974,7 +4974,7 @@ class ResizeableBuffer{
49744974
constructor(size=100){
49754975
this.size = size;
49764976
this.length = 0;
4977-
this.buf = Buffer.alloc(size);
4977+
this.buf = Buffer.allocUnsafe(size);
49784978
}
49794979
prepend(val){
49804980
if(isBuffer(val)){
@@ -4986,7 +4986,7 @@ class ResizeableBuffer{
49864986
}
49874987
}
49884988
const buf = this.buf;
4989-
this.buf = Buffer.alloc(this.size);
4989+
this.buf = Buffer.allocUnsafe(this.size);
49904990
val.copy(this.buf, 0);
49914991
buf.copy(this.buf, val.length);
49924992
this.length += val.length;
@@ -5013,7 +5013,7 @@ class ResizeableBuffer{
50135013
resize(){
50145014
const length = this.length;
50155015
this.size = this.size * 2;
5016-
const buf = Buffer.alloc(this.size);
5016+
const buf = Buffer.allocUnsafe(this.size);
50175017
this.buf.copy(buf,0, 0, length);
50185018
this.buf = buf;
50195019
}

packages/csv-parse/dist/cjs/sync.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4974,7 +4974,7 @@ class ResizeableBuffer{
49744974
constructor(size=100){
49754975
this.size = size;
49764976
this.length = 0;
4977-
this.buf = Buffer.alloc(size);
4977+
this.buf = Buffer.allocUnsafe(size);
49784978
}
49794979
prepend(val){
49804980
if(isBuffer(val)){
@@ -4986,7 +4986,7 @@ class ResizeableBuffer{
49864986
}
49874987
}
49884988
const buf = this.buf;
4989-
this.buf = Buffer.alloc(this.size);
4989+
this.buf = Buffer.allocUnsafe(this.size);
49904990
val.copy(this.buf, 0);
49914991
buf.copy(this.buf, val.length);
49924992
this.length += val.length;
@@ -5013,7 +5013,7 @@ class ResizeableBuffer{
50135013
resize(){
50145014
const length = this.length;
50155015
this.size = this.size * 2;
5016-
const buf = Buffer.alloc(this.size);
5016+
const buf = Buffer.allocUnsafe(this.size);
50175017
this.buf.copy(buf,0, 0, length);
50185018
this.buf = buf;
50195019
}

packages/csv-parse/dist/esm/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4970,7 +4970,7 @@ class ResizeableBuffer{
49704970
constructor(size=100){
49714971
this.size = size;
49724972
this.length = 0;
4973-
this.buf = Buffer.alloc(size);
4973+
this.buf = Buffer.allocUnsafe(size);
49744974
}
49754975
prepend(val){
49764976
if(isBuffer(val)){
@@ -4982,7 +4982,7 @@ class ResizeableBuffer{
49824982
}
49834983
}
49844984
const buf = this.buf;
4985-
this.buf = Buffer.alloc(this.size);
4985+
this.buf = Buffer.allocUnsafe(this.size);
49864986
val.copy(this.buf, 0);
49874987
buf.copy(this.buf, val.length);
49884988
this.length += val.length;
@@ -5009,7 +5009,7 @@ class ResizeableBuffer{
50095009
resize(){
50105010
const length = this.length;
50115011
this.size = this.size * 2;
5012-
const buf = Buffer.alloc(this.size);
5012+
const buf = Buffer.allocUnsafe(this.size);
50135013
this.buf.copy(buf,0, 0, length);
50145014
this.buf = buf;
50155015
}

packages/csv-parse/dist/esm/sync.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4970,7 +4970,7 @@ class ResizeableBuffer{
49704970
constructor(size=100){
49714971
this.size = size;
49724972
this.length = 0;
4973-
this.buf = Buffer.alloc(size);
4973+
this.buf = Buffer.allocUnsafe(size);
49744974
}
49754975
prepend(val){
49764976
if(isBuffer(val)){
@@ -4982,7 +4982,7 @@ class ResizeableBuffer{
49824982
}
49834983
}
49844984
const buf = this.buf;
4985-
this.buf = Buffer.alloc(this.size);
4985+
this.buf = Buffer.allocUnsafe(this.size);
49864986
val.copy(this.buf, 0);
49874987
buf.copy(this.buf, val.length);
49884988
this.length += val.length;
@@ -5009,7 +5009,7 @@ class ResizeableBuffer{
50095009
resize(){
50105010
const length = this.length;
50115011
this.size = this.size * 2;
5012-
const buf = Buffer.alloc(this.size);
5012+
const buf = Buffer.allocUnsafe(this.size);
50135013
this.buf.copy(buf,0, 0, length);
50145014
this.buf = buf;
50155015
}

packages/csv-parse/dist/iife/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4973,7 +4973,7 @@ var csv_parse = (function (exports) {
49734973
constructor(size=100){
49744974
this.size = size;
49754975
this.length = 0;
4976-
this.buf = Buffer.alloc(size);
4976+
this.buf = Buffer.allocUnsafe(size);
49774977
}
49784978
prepend(val){
49794979
if(isBuffer(val)){
@@ -4985,7 +4985,7 @@ var csv_parse = (function (exports) {
49854985
}
49864986
}
49874987
const buf = this.buf;
4988-
this.buf = Buffer.alloc(this.size);
4988+
this.buf = Buffer.allocUnsafe(this.size);
49894989
val.copy(this.buf, 0);
49904990
buf.copy(this.buf, val.length);
49914991
this.length += val.length;
@@ -5012,7 +5012,7 @@ var csv_parse = (function (exports) {
50125012
resize(){
50135013
const length = this.length;
50145014
this.size = this.size * 2;
5015-
const buf = Buffer.alloc(this.size);
5015+
const buf = Buffer.allocUnsafe(this.size);
50165016
this.buf.copy(buf,0, 0, length);
50175017
this.buf = buf;
50185018
}

packages/csv-parse/dist/iife/sync.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4973,7 +4973,7 @@ var csv_parse_sync = (function (exports) {
49734973
constructor(size=100){
49744974
this.size = size;
49754975
this.length = 0;
4976-
this.buf = Buffer.alloc(size);
4976+
this.buf = Buffer.allocUnsafe(size);
49774977
}
49784978
prepend(val){
49794979
if(isBuffer(val)){
@@ -4985,7 +4985,7 @@ var csv_parse_sync = (function (exports) {
49854985
}
49864986
}
49874987
const buf = this.buf;
4988-
this.buf = Buffer.alloc(this.size);
4988+
this.buf = Buffer.allocUnsafe(this.size);
49894989
val.copy(this.buf, 0);
49904990
buf.copy(this.buf, val.length);
49914991
this.length += val.length;
@@ -5012,7 +5012,7 @@ var csv_parse_sync = (function (exports) {
50125012
resize(){
50135013
const length = this.length;
50145014
this.size = this.size * 2;
5015-
const buf = Buffer.alloc(this.size);
5015+
const buf = Buffer.allocUnsafe(this.size);
50165016
this.buf.copy(buf,0, 0, length);
50175017
this.buf = buf;
50185018
}

packages/csv-parse/dist/umd/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4976,7 +4976,7 @@
49764976
constructor(size=100){
49774977
this.size = size;
49784978
this.length = 0;
4979-
this.buf = Buffer.alloc(size);
4979+
this.buf = Buffer.allocUnsafe(size);
49804980
}
49814981
prepend(val){
49824982
if(isBuffer(val)){
@@ -4988,7 +4988,7 @@
49884988
}
49894989
}
49904990
const buf = this.buf;
4991-
this.buf = Buffer.alloc(this.size);
4991+
this.buf = Buffer.allocUnsafe(this.size);
49924992
val.copy(this.buf, 0);
49934993
buf.copy(this.buf, val.length);
49944994
this.length += val.length;
@@ -5015,7 +5015,7 @@
50155015
resize(){
50165016
const length = this.length;
50175017
this.size = this.size * 2;
5018-
const buf = Buffer.alloc(this.size);
5018+
const buf = Buffer.allocUnsafe(this.size);
50195019
this.buf.copy(buf,0, 0, length);
50205020
this.buf = buf;
50215021
}

packages/csv-parse/dist/umd/sync.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4976,7 +4976,7 @@
49764976
constructor(size=100){
49774977
this.size = size;
49784978
this.length = 0;
4979-
this.buf = Buffer.alloc(size);
4979+
this.buf = Buffer.allocUnsafe(size);
49804980
}
49814981
prepend(val){
49824982
if(isBuffer(val)){
@@ -4988,7 +4988,7 @@
49884988
}
49894989
}
49904990
const buf = this.buf;
4991-
this.buf = Buffer.alloc(this.size);
4991+
this.buf = Buffer.allocUnsafe(this.size);
49924992
val.copy(this.buf, 0);
49934993
buf.copy(this.buf, val.length);
49944994
this.length += val.length;
@@ -5015,7 +5015,7 @@
50155015
resize(){
50165016
const length = this.length;
50175017
this.size = this.size * 2;
5018-
const buf = Buffer.alloc(this.size);
5018+
const buf = Buffer.allocUnsafe(this.size);
50195019
this.buf.copy(buf,0, 0, length);
50205020
this.buf = buf;
50215021
}

packages/csv-parse/lib/ResizeableBuffer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class ResizeableBuffer{
44
constructor(size=100){
55
this.size = size;
66
this.length = 0;
7-
this.buf = Buffer.alloc(size);
7+
this.buf = Buffer.allocUnsafe(size);
88
}
99
prepend(val){
1010
if(Buffer.isBuffer(val)){
@@ -16,7 +16,7 @@ class ResizeableBuffer{
1616
}
1717
}
1818
const buf = this.buf;
19-
this.buf = Buffer.alloc(this.size);
19+
this.buf = Buffer.allocUnsafe(this.size);
2020
val.copy(this.buf, 0);
2121
buf.copy(this.buf, val.length);
2222
this.length += val.length;
@@ -43,7 +43,7 @@ class ResizeableBuffer{
4343
resize(){
4444
const length = this.length;
4545
this.size = this.size * 2;
46-
const buf = Buffer.alloc(this.size);
46+
const buf = Buffer.allocUnsafe(this.size);
4747
this.buf.copy(buf,0, 0, length);
4848
this.buf = buf;
4949
}

0 commit comments

Comments
 (0)