Skip to content

Commit

Permalink
perf(csv-parse): buffer unsafe allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 18, 2021
1 parent 469fb38 commit 35c1f4a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4974,7 +4974,7 @@ class ResizeableBuffer{
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4986,7 +4986,7 @@ class ResizeableBuffer{
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5013,7 +5013,7 @@ class ResizeableBuffer{
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/cjs/sync.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4974,7 +4974,7 @@ class ResizeableBuffer{
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4986,7 +4986,7 @@ class ResizeableBuffer{
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5013,7 +5013,7 @@ class ResizeableBuffer{
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4970,7 +4970,7 @@ class ResizeableBuffer{
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4982,7 +4982,7 @@ class ResizeableBuffer{
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5009,7 +5009,7 @@ class ResizeableBuffer{
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/esm/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4970,7 +4970,7 @@ class ResizeableBuffer{
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4982,7 +4982,7 @@ class ResizeableBuffer{
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5009,7 +5009,7 @@ class ResizeableBuffer{
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/iife/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4973,7 +4973,7 @@ var csv_parse = (function (exports) {
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4985,7 +4985,7 @@ var csv_parse = (function (exports) {
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5012,7 +5012,7 @@ var csv_parse = (function (exports) {
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/iife/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4973,7 +4973,7 @@ var csv_parse_sync = (function (exports) {
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4985,7 +4985,7 @@ var csv_parse_sync = (function (exports) {
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5012,7 +5012,7 @@ var csv_parse_sync = (function (exports) {
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4976,7 +4976,7 @@
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4988,7 +4988,7 @@
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5015,7 +5015,7 @@
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/dist/umd/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4976,7 +4976,7 @@
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(isBuffer(val)){
Expand All @@ -4988,7 +4988,7 @@
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -5015,7 +5015,7 @@
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/csv-parse/lib/ResizeableBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ResizeableBuffer{
constructor(size=100){
this.size = size;
this.length = 0;
this.buf = Buffer.alloc(size);
this.buf = Buffer.allocUnsafe(size);
}
prepend(val){
if(Buffer.isBuffer(val)){
Expand All @@ -16,7 +16,7 @@ class ResizeableBuffer{
}
}
const buf = this.buf;
this.buf = Buffer.alloc(this.size);
this.buf = Buffer.allocUnsafe(this.size);
val.copy(this.buf, 0);
buf.copy(this.buf, val.length);
this.length += val.length;
Expand All @@ -43,7 +43,7 @@ class ResizeableBuffer{
resize(){
const length = this.length;
this.size = this.size * 2;
const buf = Buffer.alloc(this.size);
const buf = Buffer.allocUnsafe(this.size);
this.buf.copy(buf,0, 0, length);
this.buf = buf;
}
Expand Down

0 comments on commit 35c1f4a

Please sign in to comment.