Skip to content

Commit

Permalink
Add length to Buffer.concat invoke
Browse files Browse the repository at this point in the history
Add length to Buffer.concat invoke.
That should increase performance according to the node documenation.

If totalLength is not provided, it is calculated from the Buffer instances in list. This however causes an additional loop to be executed in order to calculate the totalLength, so it is faster to provide the length explicitly if it is already known.
  • Loading branch information
RomanBurunkov authored Jun 6, 2019
1 parent 700a5ef commit 4bfd2b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/memHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = (options, fieldname, filename) => {
let fileSize = 0; // eslint-disable-line
let hash = crypto.createHash('md5');

const getBuffer = () => Buffer.concat(buffers);
const getBuffer = () => Buffer.concat(buffers, fileSize);
const emptyFunc = () => '';

return {
Expand Down

0 comments on commit 4bfd2b7

Please sign in to comment.