1
0
mirror of https://github.com/eleith/emailjs.git synced 2024-07-03 11:38:50 +00:00

drop GC dance

This commit is contained in:
Zack Schuster 2018-07-06 11:10:40 -07:00
parent 8c44910cf9
commit 2555912d21

View File

@ -470,16 +470,14 @@ class MessageStream extends Stream {
let buffer = Buffer.isBuffer(buff) ? buff : Buffer.from(buff);
if (previous.byteLength > 0) {
const buffer2 = Buffer.concat([previous, buffer]);
previous = Buffer.alloc(0); // free up the buffer
buffer = null; // free up the buffer
buffer = buffer2;
buffer = Buffer.concat([previous, buffer]);
}
const padded = buffer.length % MIME64CHUNK;
previous = Buffer.alloc(padded);
// encode as much of the buffer to base64 without empty bytes
if (padded > 0) {
previous = Buffer.alloc(padded);
// copy dangling bytes into previous buffer
buffer.copy(previous, 0, buffer.length - padded);
}